Nicolas Filotto's answer on here is perfect: How to make post curl request in java
Here it is if you would rather stay on this page:
If I were you I would use DavidWebb a lightweight Java HTTP-Client for calling JSON REST-Services and proceed as next:
Webb webb = Webb.create();
JSONObject result = webb
.post("https://api.gupshup.io/appsdk/api/components/adduser")
.header("Content-Type", "application/x-www-form-urlencoded")
.header("apikey", "xxxx")
.body("name=abcd&email=test@test.com.com&id=abc")
.asJsonObject()
.getBody();