3

I have many project in my Gitlab and I want to add a group to all of my project.

I'm looking for a curl command to invite a group to my Gitlab project.

for example maintainer privileges

2 Answers 2

2
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.com/api/v4/groups/:id/projects/:project_id"

Please refer Gitlab docs for more details

https://docs.gitlab.com/ee/api/groups.html

Sign up to request clarification or add additional context in comments.

7 Comments

I got error: curl: (3) Port number ended with ' ' <html> <head><title>400 Bad Request</title></head> <body bgcolor="white"> <center><h1>400 Bad Request</h1></center> <hr><center>nginx</center> </body> </html>
curl --request POST--header "PRIVATE-TOKEN: xxxxxxxxxxxxxxxxx" "192.X.X.X:8000/api/v4/groups/groups/4/projects/9"
@MohammadRavanbakhsh, so you are running gitlab in your local network. are you able to hit any other api?
Yes for example I can get my project ID by api curl. gitlab is in my local network
could you check command again if u missed any space, as I could see u did not put space after --request POST in you curl command. pls separate POST--header with space
|
2

the following actually worked for me

curl -X POST --header "PRIVATE-TOKEN: xxxxxxxxxxxx" --header "Content-Type: application/json" "https://gitlab.com/api/v4/projects/<<project_id>>/share" --data '{"group_id":<<group_id>>,"group_access":<<access to given to group>>}'

where group_id is the group id of the group which you want to add as a member of the project

1 Comment

This is the correct answer to the question!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.