bam
January 5, 2022, 11:39pm
1
Hello,
I’ve followed the steps described in Trigger pipelines by using the API | GitLab ,
got an error when tried to trigger a pipeline:
$ curl -X POST \
--fail \
-F token=<token> \
-F ref=master \
https://gitlab.com/api/v4/projects/32560185/trigger/pipeline
curl: (22) The requested URL returned error: 400
The project is public:
GitLab.com
Hi @bam
I am assuming you have created the trigger token as described in the docs. Also you don’t have a master
branch on that project, only main
branch.
2 Likes
bam
January 7, 2022, 9:38pm
3
That was it! Didn’t realize auto-generated project uses odd main
branch
Thanks!
masalep
November 10, 2022, 2:25pm
6
Hi,
I have created Trigger token in project and saved it to CI/CD variables in project A. I’m trying to trigger project B pipeline with following curl. But get error 400
script:
- “curl -X POST --fail -F token=$IAC_TRIGGER_TOKEN -F ref=main https://gitlab.com/api/v4/projects/###/trigger/pipeline ”
My branch in project B is main. and token is correct. I do not know what could be the issue
Ally
December 1, 2022, 6:33am
7
@masalep I have the same issue too. Do you manage to solve it?
Might wanna check your token if it has good access to the project.
I had the same issue, my pipeline had multiple projects included in it, so I had to use a token that had access to all of those projects.
I guess you will have to create a user add that user to all projects and then have to try creating a user token to be able to trigger that pipeline.
I know long way but that how it worked for me.