改造POST返回错误请求错误400

时间:2014-04-17 08:01:41

标签: android http post http-headers retrofit

我正在尝试使用Retrofit向我的服务器发送POST请求。我按照这个开始我的服务

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

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

我创建了一个只包含整数和字符串的类:

class PostMessageBody {

    private int someId;
    private String someString;

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

我的界面有这个方法发送POST

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

这是我得到的回复的标题

[: 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]

我不知道我做错了什么。我有什么遗漏吗?

0 个答案:

没有答案
相关问题