我有一个python(flask-restful)端点,下面是swagger定义:
参数:
- name: tmp_no
in: formData
type: integer
required: true
description: |
Blah blah blah
- name: mod_no
in: formData
type: integer
required: true
description: |
Blah blah blah
- name: img_file
in: formData
type: file
required: true
description: |
Blah blah blah
- name: txt_file
in: formData
type: file
required: true
description: |
Blah blah blah
我正在尝试使用VolleyPlus从我的Android应用程序调用此端点。
SimpleMultiPartRequest smr = new SimpleMultiPartRequest(Request.Method.POST, BASE_URL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.v("Response", response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_LONG).show();
}
});
try {
smr.addFile("img_file", currentPicFile.getAbsolutePath());
smr.addFile("txt_file", currentTxtFile.getAbsolutePath());
smr.addMultipartParam("tmp_no", "multipart/form-data", Integer.toString(index));
smr.addMultipartParam("mod_no", "multipart/form-data", Integer.toString(mod));
smr.setFixedStreamingMode(true);
VolleyApplication.getInstance().addToRequestQueue(smr);
} catch (Exception e) {
}
在服务器上,我收到400:
错误:400错误请求:浏览器(或代理)发送了此服务器无法理解的请求。
我想我没有正确构建我的请求正文。知道我哪里出错了吗?
谢谢,
AB