Open Erilarn opened 4 years ago
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
?
@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?
+1
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
@ya-riel I checked it out. You're right, thank you so much!
Glad to hear that I helped. Just for the record - the credit for pinpointing the issue goes to @izikorgad ;)
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.