如何在Java中发出后卷曲请求

Irs*_*shi 5 curl jsp servlets

这是我的卷曲要求。

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'
Run Code Online (Sandbox Code Playgroud)

谁能帮我,如何使用Java Servlet发送它?

Nic*_*tto 4

如果我是你,我会使用DavidWebb一个轻量级 Java HTTP 客户端来调用 JSON REST 服务,然后继续下一步:

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();
Run Code Online (Sandbox Code Playgroud)