首页 > 解决方案 > Bitbucket 服务器 REST Api 更改文件

问题描述

在 Bitbucket 的文档中,有关于如何通过 Rest API 更改文件的信息:

curl -X PUT -u username:password \
     -F  content=@README.md  \
     -F 'message=Updated using file-edit REST API' \
     -F  branch=master \
     -F  sourceCommitId=5636641a50b \
     http://example.com/rest/api/latest/projects/PROJECT_1/repos/repo_1/browse/README.md

branch:应该在其上修改或创建路径的分支

content : 路径下文件的全部内容

message:与此更改关联的消息,用作提交消息。如果应该使用默认消息,则为 null。

sourceCommitId:文件编辑前的提交 ID,用于识别内容是否发生变化。如果这是一个新文件,则为 null

但是当我调用我的脚本时:

curl -k -X PUT \
    -H "Authorization: Basic cnVhtrhjrthhtUUFaeHN3Mg==" \
    -F  content=@README.md \
    -F "message=Updated using README" \
    -F  branch=master \
    https://bitbucket.company.com/rest/api/1.0/projects/project_name/repos/repo_name/browse/README.md

我收到这条消息:

Warning: setting file README.md  failed!

curl: (26) read function returned funny value. 

可能是什么问题呢?

标签: bitbucketbitbucket-serverbitbucket-api

解决方案


正确要求:

curl -X PUT -u 用户名:密码 -F content=一些更改-F 'message=使用文件编辑 REST API 更新' -F branch=master -F sourceCommitId=5636641a50b http://example.com/rest/api/最新的/projects/PROJECT_1/repos/repo_1/browse/README.md

内容应该没有@


推荐阅读