Retrofit POST return bad request error 400

夙愿已清 提交于 2019-12-11 11:16:47

问题


I am trying to use Retrofit to send POST request to my server. I init my service like this

RestAdapter restAdapter = new RestAdapter.Builder()
    .setEndpoint("http://myserver.com/api")
    .build();

MyApi service = restAdapter.create(MyApi.class);

I created a class which holds only integers and strings like:

class PostMessageBody {

    private int someId;
    private String someString;

    //... and there is constructor with the fields and getters of them
}

And my interface has this method to send POST

@POST("/my/server/path")
void myPostMethod(@Body PostMessageBody body, Callback<PostMessageBody> cb);

And this is the header of the response i get

[: HTTP/1.1 400 Bad Request, Cache-Control: private, no-cache, no-store,
must-revalidate, max-age=0, Connection: close, Content-Length: 2211, 
Content-Type: text/html, Date: Thu, 17 Apr 2014 07:58:20 GMT, Pragma: no-cache, 
Server: LiteSpeed, X-Android-Received-Millis: 1397721501723, 
X-Android-Response-Source: NETWORK 400, X-Android-Selected-Transport: http/1.1, 
X-Android-Sent-Millis: 1397721501348]

I don't know what I am doing wrong. Is there any part that I miss?

来源:https://stackoverflow.com/questions/23127731/retrofit-post-return-bad-request-error-400

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!