I'm trying to POST a JSONObject using the Retrofit library, but when I see the request at the receiving end, the content-length is 0
.
In the RestService interface:
@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);
And it gets called with,
mRestService.registerController(
registrationBundle,
mApplication.mSession.getCredentials().getDeviceToken(),
mApplication.mSession.getCredentials().getDeviceGuid(),
new Callback<JSONObject>() {
// ...
}
)
And I'm certain that the registrationBundle
, which is a JSONObject
isn't null or empty (the other fields are certainly fine). At the moment the request is made, it logs out as: {"zip":19312,"useAccountZip":false,"controllerName":"mine","registrationCode":"GLD94Q"}
.
On the receiving end of the request, I see that the request has Content-type: application/json
but has Content-length: 0
.
Is there any reason why sending JSON in the body like this isn't working? Am I missing something simple in using Retrofit?