2

I have a project with many branches and I would like to list all merge requests from a specific branch from the console.

I found the merge requests API and I also found that I need an HTTP request to do it from this issue like this:

curl --header "PRIVATE-TOKEN: XXXXXX" -X GET "https://gitlab.example.com/api/v3/projects/project_name/merge_requests?source_branch=XXXXXX"

But I haven't figured out yet how. The response is this:

{"message":"404 Project Not Found"}

Although the name of the project is correct.

belabrinel
  • 851
  • 8
  • 15

1 Answers1

1

project_name in your example should actually be fully namespaced project name or project ID.

eg: If your project called myproject is under a group called mygroup, the api call would be:

curl --header "PRIVATE-TOKEN: XXXXXX" -X GET "https://gitlab.example.com/api/v3/projects/mygroup%2Fmyproject/merge_requests?source_branch=XXXXXX"

If you want to use project ID instead, you can get it at https://gitlab.com/api/v4/projects/[project path URL encoded]

Ref: HOW to check id of project in gitlab

Shashank V
  • 10,007
  • 2
  • 25
  • 41