通过OpenAPI更新文件内容。
适用版本 | 企业专属版、企业标准版 |
服务接入点与授权信息
获取服务接入点,替换 API 请求语法中的 <domain> :服务接入点(domain)。
获取个人访问令牌,具体操作,请参见获取个人访问令牌。
产品 | 资源 | 所需权限 |
代码管理 | 文件 | 读写 |
请求语法
PUT https://{domain}/oapi/v1/codeup/organizations/{organizationId}/repositories/{repositoryId}/files/{filePath}
请求头
参数 | 类型 | 是否必填 | 描述 | 示例值 |
x-yunxiao-token | string | 是 | 个人访问令牌。 | pt-0fh3****0fbG_35af****0484 |
请求参数
参数 | 类型 | 位置 | 是否必填 | 描述 | 示例值 |
organizationId | string | path | 是 | 组织 ID。 | 60de7a6852743a5162b5f957 |
repositoryId | string | path | 是 | 代码库 ID 或者 URL-Encoder 编码的全路径。 | 2813489 |
filePath | string | path | 是 | 文件路径,需使用 URL-Encoder 编码进行处理。 | src/main/update.txt |
- | object | body | 否 | ||
branch | string | body | 否 | 分支名称。 | master |
commitMessage | string | body | 否 | 提交信息不能为空,不超过102400个字符。 | "" |
content | string | body | 否 | 文件内容。 | "" |
encoding | string | body | 否 | 编码规则,可选值{text, base64},默认为 text。 | text |
请求示例
curl -X 'PUT' \
'https://test.rdc.aliyuncs.com/oapi/v1/codeup/organizations/{organizationId}/repositories/{repositoryId}/files/{filePath}' \
-H 'accept: application/json' \
-H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484' \
--data '
{
"branch": "master",
"commitMessage": "",
"content": "",
"encoding": "text"
}'
返回参数
参数 | 类型 | 描述 | 示例值 |
- | object | ||
branch | string | 分支名称。 | master |
filePath | string | 文件路径。 | src/main/update.txt |
newOid | string | 文件 git object id。 | 76c3f251f414ac31f2e01faf6f2008a9d756a437 |
返回示例
{
"branch": "master",
"filePath": "src/main/update.txt",
"newOid": "76c3f251f414ac31f2e01faf6f2008a9d756a437"
}
错误码
访问错误码中心查看 API 相关错误码。
文档内容是否对您有帮助?