私のAndroidアプリケーションでは、ネットワーク操作用にGoogleのボレーを使用しています。私は要求をする必要があるが、フォームをフォームデータとして送信する必要がある場合があります。 私は他のすべてを試しましたが、私はフォームデータとしてリクエストを行うことができません。ここでAndroid:フォームデータを本文として送信するGoogle Volley
は、どのように私はボレーでその-F部分を達成することができカール
curl -X POST -H "Content-Type: multipart/form-data" -F "mobile_number=<XXXX>" "<server_url>"
のですか?サーバーが不正な要求を投げています。
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 yeを読んでいますか? t? – BNK