我正试图在我的Android应用程序中使用改装2来模拟postman的POST表单数据请求。
我正在使用RetroFit 2.3.0
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
我的邮递员查询显示为follows
我也有一些标题:
我的回答是:
[
{
"lecture": "http://2xx.xxx/videos/6xxxxxx6oxsx.mp4",
"quality": "720p",
"type": "video/mp4"
}
}
这是正确的回应。但是,当我尝试用RetroFit模拟这个请求时,我不会像邮递员那样得到结果。这是我的RetroFit数据。
@POST("/admin.php")
@FormUrlEncoded
Call<University> fetchLecture(@Field("action") String action,
@Field("id") String ids,
@Field("server") int server,
@Field("nonce") String nonce);
然后我调用方法:
private void getLecture(String dataID, String nonce){
final String ACTION = "video_info";
final int SERVER = 1;
mAPIService.fetchLecture(ACTION,dataID,SERVER,nonce).enqueue(new Callback<University>() {
@Override
public void onResponse(Call<University> call, Response<University> response) {
Log.d("dataid", "success");
Log.d("dataid","API call was a success. Response:");
Log.d("dataid", response.toString());
}
@Override
public void onFailure(Call<University> call, Throwable t) {
Log.d("dataid", "Unable to submit post to API.");
t.printStackTrace();
}
});
}
这是http日志:
03-12 18:13:54.852 12775-12930/? D/OkHttp: --> POST myendpoint....php http/1.1
03-12 18:13:54.852 12775-12930/? D/OkHttp: Content-Type: application/x-www-form-urlencoded
03-12 18:13:54.853 12775-12930/? D/OkHttp: Content-Length: 181
03-12 18:13:54.853 12775-12930/? D/OkHttp: action=video_info&id=jlIR0pR1ZDb0MzVGtSSlkxRy9tY2l0ZGJud1E9PQ%3D%3D&server=1&nonce=f326b41b57
03-12 18:13:54.853 12775-12930/? D/OkHttp: --> END POST (181-byte body)
03-12 18:13:54.993 12775-12930/? D/OkHttp: <-- 200 OK
03-12 18:13:54.993 12775-12930/? D/OkHttp: Server: VPZ
03-12 18:13:54.993 12775-12930/? D/OkHttp: Date: Mon, 12 Mar 2018 18:13:07 GMT
03-12 18:13:54.993 12775-12930/? D/OkHttp: Content-Type: text/html
03-12 18:13:54.993 12775-12930/? D/OkHttp: Content-Length: 134
03-12 18:13:54.993 12775-12930/? D/OkHttp: Connection: keep-alive
03-12 18:13:54.993 12775-12930/? D/OkHttp: Set-Cookie: PipeGuard=d00a56603601f7dbda84a42d5654df65; path=/
03-12 18:13:54.993 12775-12930/? D/OkHttp: P3P: CP="CUR ADM OUR NOR STA NID", policyref="/w3c/p3p.xml"
03-12 18:13:54.993 12775-12930/? D/OkHttp: Expires: Thu, 01 Jan 1970 00:00:01 GMT
03-12 18:13:54.993 12775-12930/? D/OkHttp: Cache-Control: no-cache
03-12 18:13:54.994 12775-12930/? D/OkHttp: Pragma: public
03-12 18:13:54.994 12775-12930/? D/OkHttp: Cache-Control: public, must-revalidate, proxy-revalidate
03-12 18:13:54.994 12775-12930/? D/OkHttp: <html><head><meta http-equiv="Refresh" content="0; URL=http://myendpoint.....php"></head><body></body></html>
03-12 18:13:54.994 12775-12930/? D/OkHttp: <-- END HTTP (134-byte body)
有人可以帮忙吗?
由于