在我的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