user1868607
user1868607

Reputation: 2610

How to create different projects within a group in Gitlab

I would like to create a list of projects within a "group" using the terminal in my machine. The group is private and I'm assuming I need a personal access token to reach it.

I saw in Gitlab API I should use POST command for this: https://docs.gitlab.com/ee/api/projects.html#create-project. But I don't see how to specify the group I want to create it into. Using this question: How do you create a project in a specific group via GitLab API?, I could write the command:

curl --header "PRIVATE-TOKEN: my-personal-access token" -X POST "https://gitlab.com/api/v4/projects?name=mylaboratory%2Fgroupname%2Fproject name"

After that I'm getting:

{"message":{"name":["can contain only letters, digits, emojis, '_', '.', dash, space. It must start with letter, digit, emoji or '_'."],"path":["can contain only letters, digits, '_', '-' and '.'. Cannot start with '-', end in '.git' or end in '.atom'"]}}

Here is my example url:

https://gitlab.eth.ch/api/v4/projects?path=lasec%2Fstudent-repos-cs372-2021%2Fgroup31

Is there a way to specify these new projects should disable rewriting commit history?

Try 1

Fixed changing .com to the relevant extension.

Try 2

From another computer the error curl: (92) HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1) goes away, this may be related to the connection as pointed in the comments.

Try 3

Upvotes: 1

Views: 1186

Answers (1)

Patrick
Patrick

Reputation: 3230

The attribute you're looking for in the API is the namespace_id, and should be the ID of the group that you'd like to create the project within. If you wanted to create a nested group structure, each group you create can accept a parent_id which should be the ID of its parent.

Upvotes: 1

Related Questions