Overview
Users transitioning from the deprecated CircleCI project creation API to the new API will observe that the a CircleCI webhook is not created in the GitHub project. This issue arises due to differences in how the new API handles project creation and webhook setup compared to the old API.
Prerequisites
A GitHub or BitBucket linked organisation
Ensure you have a valid CircleCI API token
Verify that the project name you intend to use does not already exist in your CircleCI organization
Instructions
Create a New Repository on Bitbucket or GitHub:
Set up a new repository in the VCS that you wish to integrate with CircleCI.
Create the Project on CircleCI:
Use the following command to create a project on CircleCI:
curl --request POST \
--url https://circleci.com/api/v2/organization/<vcs>/<organisation>/project \
--header "Circle-Token: $CIRCLE_TOKEN" \
--header 'content-type: application/json' \
--data '{"name":"my_repo_name"}'Follow the Project Using the API v1 Endpoint:
Execute the following command to follow the project and set up the necessary webhook:
curl -X POST https://circleci.com/api/v1.1/project/<vcs>/<organisation>/my_repo_name/follow \ -H "Circle-Token: $CIRCLE_TOKEN"
Solution
The new API requires a two-step process for project creation and webhook setup. First, create the project using the new API endpoint. Then, use the API v1 endpoint to follow the project, which establishes the webhook connection necessary for triggering builds on commits.