Trigger Build in API with node

I’m trying to trigger an additional build through the API using node. This is probably a node issue, but maybe someone here has experience with something similar.
Here’s the most basic example, which I can’t get to work:

const = 'asdfasdfasdfasdfasdf` // a token generated against my account
const options = {
  headers: {'Authorization': 'Basic ' + circleToken },
  method: 'GET'
}
fetch(`https://circleci.com/api/v1.1/me`, options)
  .then(res => res.json())
  .then(json => console.log(json))

The token works against the API in Bash like this:

curl -X POST -u ${CIRCLE_API_TOKEN} --header "Content-Type: application/json" -d '{
  "build_parameters": {
    "CIRCLE_JOB": "visual_regression_test",
    "TEST_SITES": "zilch"
  }
}' https://circleci.com/api/v1.1/me

Can you expand on that? Do you get an error? What HTTP response code do you get? etc.

{ message: 'Project not found' }
1 Like

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