使用gitlab api更新和提交文件

问题描述 投票:1回答:1

我想更新文件内容并提交它。为了能够实现它,我从网址中查看了gitlab的api; http://mygitlabadress/help/api/README.md

它说更新现有文件是作为; http://mygitlabadress/help/api/repository_files.md#update-existing-file-in-repository

我按照说明书写; http://mygitlabadress/api/v4/projects/:id/repository/files/file1%2Ffile2%2Ftest?ref=master&author_name=name%20surname&content=some%20other%20content&commit_message=update%20file&private_token=:PRIVATE_TOKEN

返回为; { “FILE_NAME”: “测试”, “FILE_PATH”: “文件1 / file2的/测试”, “大小”:5, “编码”: “的base64”, “内容”: “ZmRhcwo =”, “REF”:“主”, “blob_id”: “e1afa79f4 ......”, “commit_id”: “5d61796 ......”, “last_commit_id”: “5d617962a23c07345e68 ...”}

但是当我检查master分支上的提交时。提交没有完成。我不明白为什么会这样。上述请求不会返回错误。相反,它会在提交完成后返回。

我错过了什么?如何更新文件并提交?

git gitlab commit git-commit gitlab-api
1个回答
1
投票

看起来你正在发出GET请求而不是PUT。

你在使用卷曲吗?您应该使用doc中给出的示例curl请求:

curl --request PUT --header'PRIVANCE-TOKEN:9koXpg98eAheJpvBs5tK''https://gitlab.example.com/api/v4/projects/13083/repository/files/app%2Fproject%2Erb?branch=master&author_email=author%40example.com&author_name=Firstname%20Lastname&content=some%20other%20content&commit_message=update%20file'

© www.soinside.com 2019 - 2024. All rights reserved.