Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

only 'master' branch is triggered using v2 API #46

Open
Erilarn opened this issue Aug 16, 2019 · 6 comments
Open

only 'master' branch is triggered using v2 API #46

Erilarn opened this issue Aug 16, 2019 · 6 comments

Comments

@Erilarn
Copy link

Erilarn commented Aug 16, 2019

I'm trying to trigger a build on specified branch using such v2 API call:

curl -u ${CIRCLECI_TOKEN}: -X POST "Content-Type: application/json" -d '{"branch": "some-branch"}' https://circleci.com/api/v2/project/${project_slug}/pipeline

EXPECTED RESULT:
I expect the branch specified in branch parameter will be triggered.

ACTUAL RESULT:
Instead of specified branch master always trigger.

@peterbamsey
Copy link

This seems to be working pretty consistently for us.
@Erilarn Can I check, does ${project_slug} in your example expand to :vcs/:org/:project as per the documentation?
For example:
https://circleci.com/api/v2/project/github/mycompany/myrepo/pipeline
?

@Erilarn
Copy link
Author

Erilarn commented Aug 19, 2019

@peterbamsey
As you can see from the actual result I'm able to trigger the build using my ${project_slug}. Doesn't it mean it's correct?

@izikorgad
Copy link

+1

@ya-riel
Copy link

ya-riel commented Aug 28, 2019

Had the same problem, and found the issue.
You have to add a header with content type application/json.
The following should work for you:
curl -u ${CIRCLECI_TOKEN}: -X POST "Content-Type: application/json" -H 'Content-Type: application/json' -d '{"branch": "some-branch"}' https://circleci.com/api/v2/project/${project_slug}/pipeline

@Erilarn
Copy link
Author

Erilarn commented Aug 29, 2019

@ya-riel
I checked it out. You're right, thank you so much!

@ya-riel
Copy link

ya-riel commented Sep 3, 2019

Glad to hear that I helped. Just for the record - the credit for pinpointing the issue goes to @izikorgad
;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants