且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在java中发布post curl请求

更新时间:2023-02-24 14:35:37

如果我是你, a href =https://github.com/hgoebl/DavidWebb =nofollow> DavidWebb 用于调用JSON REST服务的轻量级Java HTTP客户端,并继续处理:

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();