小编J. *_*Doe的帖子

使用curl时Github API错误“解析JSON时出现问题”但与Postman一起工​​作正常

我正在尝试使用 Github 的 API 创建一个版本。

我的请求在 Postman 中工作正常,但无论我尝试什么,curl 总是失败,包括如果我只是使用 Postman 将 Postman 请求转换为curl。

这是我的 Postman POST 请求的正文:

{
    "tag_name": "4.2.0",
    "target_commitish": "master",
    "name": "4.2.0",
    "body": "test"
}
Run Code Online (Sandbox Code Playgroud)

我已经包含了一个“Basic”类型的授权标头,我在其中输入我的用户名和为此目的创建的令牌。
我正在执行针对 的请求https://api.github.com/repos/<myUsername>/<myRepo>/releases

正如我所说 - 它工作正常,但是当我将其转换为 curl 时,我收到错误“解析 JSON 时出现问题”。

翻译后的curl命令是:

curl --location --request POST 'https://api.github.com/repos/<myUsername>/<myRepo>/releases' \
--header 'Authorization: Basic <someHashOrSomething>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "tag_name": "4.2.0",
    "target_commitish": "master",
    "name": "4.2.0",
    "body": "test"
}'
Run Code Online (Sandbox Code Playgroud)

我将其重新格式化curl --location --request POST 'https://api.github.com/repos/<myUsername>/<myRepo>/releases' --header 'Authorization: Basic <someHashOrSomething>' --header 'Content-Type: application/json' --data-raw …

json curl github github-api

2
推荐指数
1
解决办法
5557
查看次数

标签 统计

curl ×1

github ×1

github-api ×1

json ×1