0

I am trying to edit existing file in a repo using gitlab v4 api, When I tried to edit file using postman rest client it executes without any issue, 200 status returned. When I tried the same with SpringBoot RestTemplate, I am always ending up with 400 bad request error. I am completely dont know what actually happening. Rest URL : https://domainname/api/v4/projects/51/repository/files/src%2Fmain%2Fresources%2Fapplication.yml

Request object printed using LOG is :

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

resttemplate API call,

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

When I tried the same request body with postman, Im getting 200 success

This is the rest end point, https://domainname/api/v4/projects/:projectId/repository/files/:file_path

Does anyone have any idea what is happening.

Reference doc : https://docs.gitlab.com/ee/api/repository_files.html#update-existing-file-in-repository

Nithyananth
  • 74
  • 10

1 Answers1

1

You can try an alternate option of COMMIT functionality in gitlab.

https://docs.gitlab.com/ee/api/commits.html#create-a-commit-with-multiple-files-and-actions

Nithyananth
  • 329
  • 2
  • 5
  • 17
  • As an alternate I can use this method and it is working. But as per documentation by gitlaab `file_edit` option is still not working – Nithyananth Nov 20 '18 at 13:38