【问题标题】:Converting CURL request to HTTP Request Java by method GET通过方法 GET 将 CURL 请求转换为 HTTP 请求 Java
【发布时间】:2016-04-19 06:12:32
【问题描述】:

我有以下 CURL 请求 谁能确认我接下来的 HTTP 请求是什么:

curl -i -L -H "Accept: application/json" --data "client_id=APP-UJA2FDFLIVK14WMW&client_secret=6d8d32f1-1c25-4356-8b15-4d803d9a869e&grant_type=authorization_code&code=dj4kYk&redirect_uri=https://developers.google.com/oauthplayground" "https://api.sandbox.orcid.org/oauth/token"

谁能帮我把上面的 curl 请求完全转换成 httpreq。

【问题讨论】:

  • 您真的应该先尝试一下,如果遇到困难,请发布您的问题。

标签: java curl get


【解决方案1】:

你应该看看这个帖子:Using java.net.URLConnection to fire and handle HTTP requests

您应该能够按原样传递数据部分:

URLConnection connection = new URL(url + "?" + dataString).openConnection();

使用:

connection.setRequestProperty("Accept: application/json", charset);

添加标题

这是一个起点……

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-25
    • 2020-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-04
    • 1970-01-01
    相关资源
    最近更新 更多