Retrofit POST return bad request error 400

2019-07-27 06:40发布

问题:

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?