Bulk moving issues via GitLab API fails with error 404

Dear community,

I am trying to bulk move issue between projects via GitLab’s API. According the documentation, this action requires a simple POST request. Unfortunately, I keep running into 404s. Below, I am posting my Python script which takes advantage of the requests module. Any hints are much appreciated.

import requests

gitlab_url = "https://gitlab-example.com"
headers = {"PRIVATE_TOKEN": "fooBar"}
r = [requests.post(
        gitlab_url + f"/projects/155/issues/{k}/move",
        headers = headers,
        data = {"to_project_id": 158},
        verify = False)
        for k in range(56, 82)]

Hi,

Based on your python request, the URL doesn’t seem to match from the docs:

curl --header "PRIVATE-TOKEN: <your_access_token>" --form to_project_id=5 "https://gitlab.example.com/api/v4/projects/4/issues/85/move"

since you have gitlab_url you automatically append to it /projects/155/issues, instead of /api/v4/projects/155/issues

Add to gitlab_url, so that it looks like:

gitlab_url = "https://gitlab-example.com/api/v4"

perhaps it’ll work then?

1 Like