在我的Android应用程序中,我正在使用谷歌的排球进行网络操作。有一种情况我需要提出请求,但将身体作为表单数据发送。 我已经尝试了其他一切,但我无法将请求作为表单数据。Android:将身份数据发送为身体Google Volley
这里是卷曲
curl -X POST -H "Content-Type: multipart/form-data" -F "mobile_number=<XXXX>" "<server_url>"
我怎样才能实现凌空-F一部分?服务器正在抛出不好的请求。
这是我做了什么:
final JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.POST, URLFactory.OTP_URL,
null, listener, errorListener){
@Override
public byte[] getBody() {
final JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("mobile_number", mobileNumber);
} catch (JSONException e) {
e.printStackTrace();
return null;
}
return jsonObject.toString().getBytes();
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
final HashMap<String, String> headers = new HashMap<>();
headers.put("Content-Type", "multipart/form-data");
return headers;
}
};
请帮我在这。
你看过http://stackoverflow.com/questions/32240177/working-post-multipart-request-with-volley-and-without-httpentity?lq=1你们T' – BNK