How to POST raw whole JSON in the body of a Retrofit request?

This question may have been asked before but no it was not definitively answered. How exactly does one post raw whole JSON inside the body of a Retrofit request?

See similar question here. Or is this answer correct that it must be form url encoded and passed as a field? I really hope not, as the services I am connecting to are just expecting raw JSON in the body of the post. They are not set up to look for a particular field for the JSON data.

I just want to clarify this with the restperts once and for all. One person answered not to use Retrofit. The other was not certain of the syntax. Another thinks yes it can be done but only if its form url-encoded and placed in a field (that’s not acceptable in my case). No, I can’t re-code all the services for my Android client. And yes, it’s very common in major projects to post raw JSON instead of passing over JSON content as field property values. Let’s get it right and move on. Can someone point to the documentation or example that shows how this is done? Or provide a valid reason why it can/should not be done.

UPDATE: One thing I can say with 100% certainty. You CAN do this in Google’s Volley. It’s built right in. Can we do this in Retrofit?

26 Answers
26

Leave a Comment