API For creating issue from template in self-hosted GitLab

Hi everyone…
I am solving a problem with creating an issue via API, from template on a self-hosted solution. In the documentation I only found a solution for GitLab hosted here. Is there any such possibility also on self-hosted installation?

Hi,

You basically adapt the URL based on your Gitlab URL, so for example from here: REST API | GitLab

curl "https://gitlab.example.com/api/v4/projects"

you change gitlab.example.com to the IP/FQDN that you use for your server. For creating an issue: Issues API | GitLab

So you’ll see the URL for creating a new issue, which goes on the end of your base API url of https://gitlab.example.com/api/v4 and you would have to use the POST method as the documentation says.

Yes, I thought the same thing, and I tried this:

https://gitlab.ourdomain.net/api/v4/projects/XXXX/issues/new?issuable_template=name

but I get 404 response… Other (get templates, get issues) works.

The docs say that required is ID and title. Further down from the section I linked:

curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/4/issues?title=Issues%20with%20auth&labels=bug"

Your 404 is most likely because the required fields were not provided.

1 Like

OK, but if I use this:

curl --request POST --header “PRIVATE-TOKEN: XXXXXXXXXXXXX” “https://gitlab.ourdomain.net/api/v4/projects/XXXXX/issues?title=Test&issuable_template=name

Issue was create, but the template does not use…

From the docs, it looks like that option isn’t available. That option doesn’t appear under the new issue section in the Gitlab docs. The link I posted shows all options that are available for you to use.

Yes, that’s what I finally came to :slight_smile:

Anyway, thank you for your help. I finally solved it using REST API and CI/CD :slight_smile:

1 Like