【问题标题】:Using Github api to create a file in postman使用 Github api 在 postman 中创建文件
【发布时间】:2022-08-02 15:56:09
【问题描述】:

我是 GitHub API 的新手,并尝试使用 API 在我的存储库中创建一个文件。 我正在使用邮递员首先检查 API。

PUT Method:

URL:https://api.github.com/repos/KaranS-hexaware/Rapidx_Documentation/contents/text.txt

Body:{
\"message\":\"my commit message\",
\"content\":\"bXkgbmV3IGZpbGUgY29udGVudHM=\"
}

Header
Authorization:Bearer ****************************************************
Content-Type:application/vnd.api+json

回应是:

{
\"message\": \"Not Found\",
\"documentation_url\": \"https://docs.github.com/rest/reference/repos#create-or-update-file-contents\"
}

我可以就我在这里缺少的内容获得一些意见吗?

    标签: github-api


    【解决方案1】:

    create file contents API 示例是:

    curl \
      -X PUT \
      -H "Accept: application/vnd.github+json" \ 
      -H "Authorization: token <TOKEN>" \
      https://api.github.com/repos/OWNER/REPO/contents/PATH \
      -d '{"message":"my commit message","committer":{"name":"Monalisa Octocat","email":"octocat@github.com"},"content":"bXkgbmV3IGZpbGUgY29udGVudHM="}'
    

    检查这些标头(与您的标头略有不同)是否有所作为并让您的呼叫成功。

    【讨论】:

      猜你喜欢
      • 2020-10-17
      • 2018-10-05
      • 1970-01-01
      • 2022-07-21
      • 2017-03-29
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多