dtmwnqng38644 2016-04-21 21:58
浏览 679
已采纳

HTTPClient代码中的CURL命令

I'm planning on working with a text uploading site, http://textuploader.com/, but I don't seem to understand this. I probably haven't looked hard enough, but that's not the point. What I'm really looking for is just simply how to do these commands, or just how to use "HTTPClient" to do these sorts of things. The site with all of the commands and information is here. Also, just for convenience, I should leave the most important ones for me, in this post:

POST: /posts

This will allow you to post to your account.

{
   "Title": "Sample Title",
   "Content": "Post body goes here.",
   "Type": "public"
}

Example:

curl -X POST "http://api.textuploader.com/v1/posts" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-TextUploader-API-Key: your-api-key-here" \
-v \
-d '{"title": "Sample Title", "content": "Post body goes here.", "type": "public"}'

And this:

GET: /posts/[shortcode]

This method will return the complete body of the requested shortcode.
  • 写回答

1条回答 默认 最新

  • douxiong2738 2016-04-21 22:12
    关注

    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();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 有偿求qftp工具。能连接,下载文件,发送代码,windows环境,最好qt6 要qt creator写的
  • ¥70 刚刚看到一个人的网站居然是通过cname访问的
  • ¥15 Attributeerror:super object has no attribute '__sklearn_tags__'_'
  • ¥15 逆置单链表输出不完整
  • ¥15 宇视vms-B200-A16@R启动不了,如下图所示,在软件工具搜不到,如何解决?(操作系统-linux)
  • ¥500 寻找一名电子工程师完成pcb主板设计(拒绝AI生成式答案)
  • ¥15 关于#mysql#的问题:UNION ALL(相关搜索:sql语句)
  • ¥15 matlab二位可视化能否针对不同数值范围分开分级?
  • ¥15 已经创建了模拟器但是不能用来运行app 怎么办😭自己搞两天了
  • ¥15 关于#极限编程#的问题,请各位专家解答!