2

Currently we're still using gitLab with a single group for all teams. We need to switch from everyone using branches on one main repo to having forked repositories in different groups.

We need to be able to

-Automatically create a new group with the existing repositories forked and branched

The current setup returns a 404 for some reason. curl --request POST --header "PRIVATE-TOKEN: xxxxxxxxxxxxxxxx" http://gitlab.exampleRepo.com/api/v4/projects/84/myNamespace/fork

Any help would be great guys.

Dante
  • 548
  • 1
  • 7
  • 19

2 Answers2

3

Got it sorted in the end. I needed to put data with namespace before --header in the command. I used curl --request POST --data "namespace=team_name" --header "PRIVATE-TOKEN: xxxxxxxxxxxx" gitlab.exampleRepo.com/api/v4/projects/project_ID/fork

Dante
  • 548
  • 1
  • 7
  • 19
  • Interestingly for me neither the option name nor the option path worked, so I had to rename it afterwards, see [API](https://docs.gitlab.com/ee/api/projects.html#fork-project) – Clerenz May 13 '19 at 11:35
2

Use double quotes around the url to pass multiple option (&).

curl --request POST --data "namespace=team_name" --header "PRIVATE-TOKEN: xxxxxxxxxxxx" "https://gitlab.com/api/v4/projects/project%2project_ID/fork?path=test_path&name=test_name"
Martin Ro
  • 33
  • 1
  • 5