HTTP 400 error on triggering a pipeline

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:

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

That was it! Didn’t realize auto-generated project uses odd main branch :slight_smile:
Thanks!

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

@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.