spring-boot - Gitlab API更新存储库中的现有文件,在rest模板中给出400错误
问题描述
我正在尝试使用 gitlab v4 api 在 repo 中编辑现有文件,当我尝试使用 postman rest 客户端编辑文件时,它执行时没有任何问题,返回 200 状态。当我对 SpringBoot RestTemplate 进行相同尝试时,我总是以 400 bad request 错误告终。我完全不知道实际发生了什么。休息网址: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-existing-file-in-repository
解决方案
COMMIT
您可以在 gitlab中尝试其他功能选项。
https://docs.gitlab.com/ee/api/commits.html#create-a-commit-with-multiple-files-and-actions
推荐阅读
- angular-ui-router - 如何在多布局角度 12 中呈现错误页面
- javascript - React App 错误中的 Onclick 事件格式
- javascript - Node.js 的 `fs` 模块如何将 `PathLike` s 转换为路径?
- html - 识别文本出现最少次数的元素的正确 XPath 是什么?
- python-3.x - 在python中计算一个系列
- python - 在运行的 Docker 容器中激活 conda env?
- python - 由于影响相机移动的奇怪碰撞/跳跃值,屏幕看起来像是在下沉
- go - golang为什么不能在主线程上将值传递给通道
- java - 尝试从 StatusBarNotification 获取应用程序名称时获取 NameNotFoundException
- c++ - 双重释放或损坏(fasttop),使用转换指针来映射一个类