Java – How to post JSON data to a server using Java


I am trying to build a POST request to send JSON data to a server using a REST api.

As the JSON code will be embedded in the request body as a request parameter value, do I need to encode the value to escape special characters like '{}[]' you typically find in JSON syntax.

Is there any utility library to do that ?


Best Solution

The body of the request needs not to be URL encoding. Have a look at HttpClient. It is the de-facto library for issuing POST requests.