Reputation: 97
I tried using POST /projects/xx/merge_requests/xx/approve
requests. After requesting the request, returned "message": "401 Unauthorized"
,I also added the request header PRIVATE-TOKEN
。
Upvotes: 1
Views: 1151
Reputation: 1327004
First, make sure (as documented in GitLab Merge Requests Approvals) that:
approval_password
parameterSecond, the curl call would be of the form (GitLab API)
curl -XPOST "https://gitlab.com/api/v4/projects/$CI_MERGE_REQUEST_PROJECT_ID/merge_requests/$CI_MERGE_REQUEST_IID/notes" \
-H "PRIVATE-TOKEN: $MR_TOKEN" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode 'sha=<sha>&approval_password=<password>'
^^^^^^^^^^^^^^^^^
(only if the project requires it)
With sha
matching the current HEAD of the merge request for the approval to be added.
Upvotes: 1