5

This is my curl request.

curl -X POST --header 'Content-Type: application/x-www-form-urlencoded' 
--header 'Accept: application/json' --header 'apikey: xxxx' -d 
'name=abcd&email=test@test.com.com&id=abc' 
'https://api.gupshup.io/appsdk/api/components/adduser'

Can anybody help me, how to send it using java servlet?

Vinoth Krishnan
  • 2,925
  • 6
  • 29
  • 34
Irshad Qureshi
  • 65
  • 1
  • 2
  • 6

1 Answers1

4

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();
Nicolas Filotto
  • 43,537
  • 11
  • 94
  • 122