Is it possible to trigger a workflow on a specific branch using API

I tried all sorts of options but not much luck. With /pipelines API, the request succeeded, but it kicked off a workflow on master, instead of the branch I specified. notice that I specified branch both in url parameter, as well as body - but neither worked.

    curl -X POST \
      'https://circleci.com/api/v2/project/github/twilio/twilio-video.js/pipeline?circle-token=xxx&branch=makarand_circleci_releasetool' \
      -d '{
      "branch": "makarand_circleci_releasetool"
      "parameters": {
        "run_release_steps": true,
        "run_stable_only": true
      }
    }'

Same issue with: /build endpoint, it kicked off the workflow build on master branch.

    curl -X POST \
      'https://circleci.com/api/v1.1/project/github/twilio/twilio-video.js/build?circle-token=xxx&branch=makarand_circleci_releasetool' \
      -d '{
      "branch": "makarand_circleci_releasetool"
    }
    '

and Finally:

    curl -X POST \
      'https://circleci.com/api/v1.1/project/github/twilio/twilio-video.js/tree/makarand_circleci_releasetool?circle-token=xxx' \
      -d '{
      "build_parameters": {
        "RUN_EXTRA_TESTS": "true"
      }  
    }
    '

did kick off something on the correct branch, but it failed with build error saying:

  • Configuration version 2.1 requires the “Enable Pipelines” project setting. Enable pipelines under Project Settings → Advanced Settings. In order to retrigger pipelines, you must push a new commit.
  • Cannot find a job named build to run in the jobs: section of your configuration file.
    If you expected a workflow to run, check your config contains a top-level key called ‘workflows:’

I do have pipeline enabled on my repro.

Thanks,
Makarand

1 Like

Hello, I have the exact same issue, any updates concerning this issue? Thanks

@makarandp0 did you find a solution to this?
Also experiencing the same issue.

@circlecibeginner, I was able to get this working with v2 api like:

curl -u ${CIRCLECI_TOKEN}: -X POST \
  --header 'Content-Type: application/json' \
  -d '{
    "branch": "your_branch",
}' \
https://circleci.com/api/v2/project/github/twilio/twilio-video.js/pipeline
2 Likes

Your solution worked for me too. You’ll want to validate that what is passed with “-d” is valid json. I had to remove the , after the branch definition.