API to Trigger a new Build by Project (preview) fails

I’ve enabled the preview feature in my projects settings. I’ve created a new api key in the project, with ‘all’ permissions.

When trying to trigger the project via:
curl -X POST --header “Content-Type: application/json” -d ‘{“branch”:“develop”}’ “https://circleci.com/api/v1.1/project/github///build?&circle-token=xxxxxxxxxxxxx”

… it fails with {“message”:“An internal server error occurred.”}

I just received an email saying this is possible.
And please stop closing tickets when issues are not solved.

Mostly, no-one is doing that - it is an automatic feature of the board, presumably to prevent necroposting. If you see an old post that is closed, you can create a new post and link to the old one.

The /// looks suspect to me. Are there meant to be two null/empty values in here?

More like this:
curl -X POST https://circleci.com/api/v1.1/project/github/username/projectname/build?branch=develop&circle-token=xxxxxxxxxxxxx

@mt-micky - one thing to check first is whether you turn on the “build processing” feature under “Advanced Settings” on your project settings page – that’s required for the new build triggering endpoint. If that’s the issue, we can make the error message better. If that’s not the issue, let us know.

1 Like

Yes, it’s turn on. That’s how I’m testing the feature but still getting “An internal server error occurred.”

Hey! Did you have any luck with this? I’m actually getting the same error.

I am having the issue with /build/ api call.

The error is : “message” : “Project not found”, however i can get the project info when calling the api.
The command i’m running is:

curl -X POST https://circleci.com/api/v1.1/project/:vcs-type/:username/:project/build?branch=branch_name&circle-token=circle_token/

curl -u 'user:token' -d build_parameters[CIRCLE_JOB]=build https://circleci.com/api/v1.1/project/github/org/repo/tree/master

Same here “Project not found” :disappointed:

Hitting exactly the same error. The identical curl request succeeds if I submit it locally but fails when triggered from within a CircleCI workflow.

Can someone help please? This is the last thing stopping me from switching our CI/CD system over to CircleCI…

curl -d 'build_parameters[CIRCLE_JOB]=build' 'https://circleci.com/api/v1.1/project/github/MY_ORG/MY_REPO/tree/master?circle-token=TOKEN'

this works!!!

1 Like

Ridiculous. Please stop closing active unsolved threads.

Anyone know when they’ll finish this feature that was complained about some 2 years ago now?

Why force us into 2.0 if it’s not ready for production.

p.s. Whatever is documented over here does not tell us where to specify the workflow and looks nothing like the commands people are using in this thread.

https://circleci.com/docs/api/v1-reference/#new-project-build

Unsolved threads should be banished, using this simple charm. Keep practising! :sparkles:

using this simple charm

Completely over my head. Until I remember that author applies new meanings to words in ridiculous ways.

All my metaphors today take on a Harry Potter theme. For example, if something unpleasant jumps out at me and catches me by surprise, I use humour to defeat it, and send it scurrying away. :rat: That’s why there are no Boggarts in this thread.

curl -X POST --header "Content-Type: appliation/json" -d '{"branch":":branch"}' -d 'build_parameters[CIRCLE_JOB]=build' https://circleci.com/api/v1.1/project/github/:username/:repo/tree/:branch?circle-token=:token

Configuration errors: 2 errors occurred:

* Configuration version 2.1 requires the "Enable Build Processing" project setting. Enable Build Processing under Project Settings -> Advanced Settings. In order to retrigger build processing, 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:'
  • version: 2.1 is set.
  • “Enable Build Processing” is enabled.
  • build exists under jobs:.
  • If I give a workflow name it errors just the same. (including still talking about build job rather than the workflow name)

It appears one issue is that circle-token has without documentation changed to no longer mean “Project API key” but “Personal API key”.

For a version 2.1 project, using orbs and workflows.

https://circleci.com/api/v1.1/project/:vcs/:username/:repo/build, passing {"branch":"branchname"} as payload works as expected.

https://circleci.com/api/v1.1/project/:vcs/:username/:repo/tree/:branch, passing {"build_parameters":{"VAR":"true"}} doesn’t work, fails with the exact same error as @yellow encountered.
This seems to happen because my configuration is not being processed: if I navigate to the “Configuration” tab, I see that my orbs haven’t been resolved.

The reason I can’t use the former request is that I need to provide a custom environment variable to my workflow but that’s not supported.
The latter form does support it, but it doesn’t seem to process my configuration before running.

My specific use case is that I want to trigger a subset of my workflow.
I could declare another workflow in my configuration, just like I do for scheduled workflow runs, but there’s no API to trigger a specific workflow, I can only trigger my main workflow from an API.
My attempted workaround was to pass an environment variable and abort early on steps I don’t want to run, which is very rudimentary but would work given the current API constraints.

there NO any example for all API!!!

It’s documented here https://circleci.com/docs/api/#trigger-a-new-build-by-project-preview

Can you explain what you mean by no example?