GitLab REST API Endpoint for changes requested on merge-requests

I am using this endpoint /api/v4/groups/::group_id/merge_requests to fetch merge requests in a group.
However what I need is the number of times changes were requested on a particular merge request by the reviewer, and the content of those requested changes if possible.
Is this possible with the available REST endpoints?

Hi,

please be as clearly as possible on what you are trying to get as information and what you want to do. Otherwise it’s very hard to understand what you are trying to achieve and give you the hints you might need. :wink:

What do you mean exacly with “number of times changes requested on a particular merge request” or “content of those requests”?

  • Pushes to a specific merge request?
  • Commits within a specific merge request?
  • The files changed within the merge request?
  • The diff of the merge request?

You could also take a deep look in the documention of the Merge Requests API. Maybe you can find the right way to get the data you need yourself.

kind regards
Markus

What I meant was number of times changes were requested on a particular merge request by the reviewer. For example, a merge request is raised and a reviewer is assigned. Then, the reviewer reviews and requests changes in the merge request.
The developer makes the changes, pushed the code, and resolves the issues. The reviewer requests more changes on the updated merge request.
In this case, “number of times changes requested on a particular merge request” would be two so far. The “content of those requests” could be the review comments left by the reviewer.
Since the merge request has not yet been closed, the value can increase in case the reviewer requests more changes in this merge requests before approving it.

Well if you start from a group i think this could be solved by:

  1. Getting all open merge requests from a group with /api/v4/groups/:id/merge_requests?state=opened
  2. Since 1. has all the data needed you can now get the discussion items for a specific iid of a merge request of a project id /api/v4/projects/:id/merge_requests/:merge_request_iid/discussions
  3. Summarize what you want to count based in the data received from 2.

kind regards
Markus

1 Like

Thanks @mkoehl , this works. Has this been documented in the GitLab docs? I went through the merge_requests endpoint for both groups and projects, and did not come across this.
Could you please include the link as well!

Hi,

the link /api/v4/projects/:id/merge_requests/:merge_request_iid/discussions points directly to the documentation for the discussions API.

If you’re searching for anything within the GitLab API I advice you to first take a look at the project/group or standalone ressources on the REST API resources docs and use the links from there which take you to the endpoints you might need for your specific purpose.

It’s all there. You just have to find it. Because the documentation is so massive this is not always easy for someone that just starts using the API, but doable. :wink:

kind regards
Markus