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 protected]&id=abc' 'https://api.gupshup.io/appsdk/api/components/adduser' 

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

4
  • Possible duplicate of HTTP Json requests in Java? Commented Apr 7, 2016 at 11:43
  • What do you mean by "send it using java servlet"? Do you want to do the same query but in Java? Commented Apr 7, 2016 at 13:22
  • yes,i want to send it by java Commented Apr 7, 2016 at 13:48
  • Hi Nicolas sorry for delay. Do i need to add any library for Webb Class? Commented Apr 8, 2016 at 5:37

1 Answer 1

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 protected]&id=abc") .asJsonObject() .getBody(); 
Sign up to request clarification or add additional context in comments.

3 Comments

Which library need to add for Webb class
@IrshadQureshi This one search.maven.org/…
honestly i didt'n understand how to use it in my java web application

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.