Issues trying to use gitlab api to mirror repo from github to gitlab, 404 error

  1. I’m creating a python script using either the requests lib, or python-gitlab to try and set a mirroring-repositorie to PULL from a repo in github. (github >> gitlab).
  2. when using a curl post, or the requests lib in python I’m getting a 404, the URL apparently does not exist.

`gitdata = {
“import_url”: “https://:@github.com//.git”,
“mirror”: ‘true’,
“mirror_user_id”: userid,
“mirror_trigger_builds”: ‘false’,
“only_mirror_protected_branches”:‘false’,
“mirror_overwrites_diverged_branches”:‘false’
}

mirroring_request = requests.post(url, headers=custom_headers, json=gitdata)`

The error I get from that code is this: (the xxxxx for the repoid)

requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://gitlab.com/api/v4/projects/xxxxx/mirror/pull

The last test I did why trying to follow the "Start the pull mirroring process for a Project " document: curl --request POST --header "PRIVATE-TOKEN: <token>" "https://gitlab.com/api/v4/projects/<repoid>/mirror/pull" The return is this: {"message":"The project is not mirrored"}

I will really appreciate the help. hvithval

GitLab’s v4 APIs currently do not provide a way to setup pull-direction mirrors. This issue tracks the feature request to cover setting up a pull configuration in future.

Use the Edit project (PUT) API to setup a pull mirror configuration in a project, and then use the mirror pull API to trigger it. Note that the simple trigger endpoint v4/projects/:id/mirror/pull is an empty POST and will not accept a payload in the request.

Edit: Updated my incorrect response, thanks to user Karina Costa.