Gitlab API更新存储库中的现有文件,在rest模板中给出400错误



我正在尝试使用gitlab v4-api编辑repo中的现有文件,当我尝试使用postlerrest客户端编辑文件时,它执行时没有任何问题,返回了200状态。当我用SpringBoot RestTemplate尝试同样的方法时,我总是以400个坏请求错误告终。我完全不知道到底发生了什么。休息URL:https://domainname/api/v4/projects/51/repository/files/src%2Fmain%2Fresources%2Fapplication.yml

使用LOG打印的请求对象为:

[branch=master, content=server:port: value, commit_message=port number updated, file_path=src%2Fmain%2Fresources%2Fapplication.yml]

resttemplate API调用,

HttpEntity<?> entity = new HttpEntity<Object>(request, header);
restTemplate.exchange(gitlabApiUrl, HttpMethod.PUT, entity, Object.class);

当我和邮递员尝试相同的请求体时,我获得了200次成功

这是休息的终点,https://domainname/api/v4/projects/:projectId/repository/files/:file_path

有人知道发生了什么事吗。

参考文件:https://docs.gitlab.com/ee/api/repository_files.html#update-存储库中的现有文件

您可以在gitlab中尝试COMMIT功能的替代选项。

https://docs.gitlab.com/ee/api/commits.html#create-具有多个文件和账户的通信

最新更新