[go: up one dir, main page]

Skip to content

Better documentation for setting up HTTPS pull mirroring using the API

Hello, I've been trying to mirror a gitlab repo to PULL from a github repo. When done on the UI I had no issues at all, but when I try using either you gitlab API, or the python-gitlab I always end up in the same response/ issue:

{"message":"404 Project Not Found"} or {"message":"The project is not mirrored"}

This is what I'm trying to do:

` ###Preparing variables for the request-post to Gitlab url = f"""https://gitlab.com/api/v4/projects/{repo_id}/mirror/pull""" custom_headers = { 'PRIVATE-TOKEN': gitlab_token }

gitdata = {
	"import_url": "https://<githubuser>:<githubtoken>@github.com/<group>/<reponame>.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

Edited by Nick Thomas