【发布时间】:2019-11-04 06:13:19
【问题描述】:
我已阅读有关此主题的其他帖子,但没有一个对我有用。
使用getParams() 发送原始数据,但一些帖子显示使用相同的发送表单数据。
我尝试使用getBody() 和getParams() 进行发送,但都返回了错误。
这就是我想要做的
StringRequest stringRequest = new StringRequest(Request.Method.POST, UPDATE_PROFILE_IMAGE_URL, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d(TAG, "onResponse: " + response);
Toast.makeText(ProfileActivity.this, String.valueOf(response), Toast.LENGTH_SHORT).show();
}
}, Methods.errorListener) {
@Override
public String getBodyContentType() {
return "application/json; charset=utf-8";
}
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
params.put("id", "1");
params.put("image", encodedString);
return params;
}
};
requestQueue.add(stringRequest);
我尝试过使用 Postman,但只有表单数据有效。
【问题讨论】:
标签: android post android-volley postman