使用gitlab API更新和提交文件 [英] Updating and committing file by using gitlab api

查看:1297
本文介绍了使用gitlab API更新和提交文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更新文件内容并提交.为了实现它,我从url看了gitlab的api; http://mygitlabadress/help/api/README.md

I want to update file content and commit it. To be able to achieve it, I looked the api of gitlab from the url; http://mygitlabadress/help/api/README.md

它表示更新现有文件的操作是这样的; http://mygitlabadress/help/api/repository_files.md#更新存储库中的现有文件

It says Updating existing file is done as; http://mygitlabadress/help/api/repository_files.md#update-existing-file-in-repository

我按照指示进行书写;

I follow the instructions and write; 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 =","ref":"master ," blob_id:" e1afa79f4 ...," commit_id:" 5d61796 ...," last_commit_id:" 5d617962a23c07345e68 ...}

This returns as; {"file_name":"test","file_path":"file1/file2/test","size":5,"encoding":"base64","content":"ZmRhcwo=","ref":"master","blob_id":"e1afa79f4...","commit_id":"5d61796...","last_commit_id":"5d617962a23c07345e68..."}

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

But when I check commits on master branch. The commit is not done. I don't understand why this is happening. The above request doesn't return an error. On the contrary, it returns as commit is done.

我想念什么?如何更新并提交文件?

What am I missing? How can I update the file and commit it??

推荐答案

您似乎在发出GET请求而不是PUT.

It looks like you are making a GET request instead of a PUT.

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

Are you using curl ? You should use the example curl request given in the doc :

curl --request PUT --header'PRIVATE-TOKEN:9koXpg98eAheJpvBs5tK'' 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆