我正在尝试使用Retrofit库POST一个JSONObject,但是当我在接收端看到请求时,内容长度为0
.
在RestService接口中:
@Headers({
"Content-type: application/json"
})
@POST("/api/v1/user/controller")
void registerController(
@Body JSONObject registrationBundle,
@Header("x-company-device-token") String companyDeviceToken,
@Header("x-company-device-guid") String companyDeviceGuid,
Callback<JSONObject> cb);
Run Code Online (Sandbox Code Playgroud)
它被调用,
mRestService.registerController(
registrationBundle,
mApplication.mSession.getCredentials().getDeviceToken(),
mApplication.mSession.getCredentials().getDeviceGuid(),
new Callback<JSONObject>() {
// ...
}
)
Run Code Online (Sandbox Code Playgroud)
我确定registrationBundle
,这是一个JSONObject
非空或空(其他字段肯定是好的).在提出请求时,它将注销为: {"zip":19312,"useAccountZip":false,"controllerName":"mine","registrationCode":"GLD94Q"}
.
在请求的接收端,我看到请求已经Content-type: application/json
有了Content-length: 0
.
是否有任何理由为什么在这样的身体中发送JSON不起作用?我在使用Retrofit时遗漏了一些简单的东西吗?