Alternative to /tree/<branch> in API v2 or circleci 2.1

Hi there,

Does anyone have a solution to triggering jobs within circleci 2.1?

I’m looking for an alternative to:
https://circleci.com/api/v1.1/project////tree/

where I can specify a branch within the url.

I’ve tried:

-d ‘{“branch”: “$branch”}’

but this always executes the pipeline on the default github branch.

First, you should read this if you haven’t already:

So with the 1.2 API, you are triggering a pipeline, and instead of including the branch in the URL that you are POSTing to, you will specify “branch” as a top-level parameter in your payload.

Example POST:
https://circleci.com/api/v2/project/gh/{owner}/{project}/pipeline

Payload:

{
  "branch": "myBranch"
}
1 Like

In my case the branch payload was not enough as previously I was passing in the branch within the url as well as the workflow to trigger.

Something like:

-d ‘{“branch”: “$CIRCLE_BRANCH”, “parameters”: {“workflow”: my-workflow }}’

https://discuss.circleci.com/t/circleci-2-1-is-it-possible-to-trigger-a-job-through-api/26294/10

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.