I would like to make a simple HTTP POST using JSON in Java.
Let\'s say the URL is www.site.com
and it takes in the value {\"name\":\"mynam
I recomend http-request built on apache http api.
HttpRequest httpRequest = HttpRequestBuilder.createPost(yourUri, String.class)
.responseDeserializer(ResponseDeserializer.ignorableDeserializer()).build();
public void send(){
ResponseHandler responseHandler = httpRequest.execute("details", yourJsonData);
int statusCode = responseHandler.getStatusCode();
String responseContent = responseHandler.orElse(null); // returns Content from response. If content isn't present returns null.
}
If you want send JSON
as request body you can:
ResponseHandler responseHandler = httpRequest.executeWithBody(yourJsonData);
I higly recomend read documentation before use.