2

我想更新文件内容并提交它。为了能够实现,我从 url 中查看了 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":"test","file_path":"file1/file2/test","size":5,"encoding":"base64","content":"ZmRhcwo=","re​​f":"master ","blob_id":"e1afa79f4...","commit_id":"5d61796...","last_commit_id":"5d617962a23c07345e68..."}

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

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

4

1 回答 1

2

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

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

curl --request PUT --header 'PRIVATE-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 '

于 2017-08-24T08:48:05.240 回答