Skip to main content

[WIP] Resolving Issues with CircleCI's New Project Creation API

Overview

When migrating from the deprecated project creation API to the new one, users may encounter issues with project creation and webhook setup. The new API endpoint creates projects differently than the old one, requiring an additional step to establish the webhook connection with your VCS provider.

Solution

Understanding the API Differences

The original (deprecated) API endpoint: - Checks for the corresponding repository in your VCS provider - Creates a project on CircleCI under the same name - Sets up the OAuth pipeline link to the VCS repository

The new API endpoint: - Creates a project under any name desired - Has no intrinsic link to the VCS repository - Does not automatically create an OAuth pipeline link to the VCS repository

Required Steps for Project Creation

To properly create a project using the new API, you need to:

  1. Create the project using the new V2 API endpoint:

     curl --request POST \ 
       --url https://circleci.com/api/v2/organization/bb/{org-name}/project \ 
       --header "Circle-Token: $CIRCLE_TOKEN" \ 
       --header 'content-type: application/json' \ 
       --data '{"name":"my_repo_name"}'
  2. Follow the project using the V1 API endpoint to create the webhook:

    curl -X POST https://circleci.com/api/v1.1/project/bb/{org-name}/my_repo_name/follow -H "Circle-Token: $CIRCLE_TOKEN"

This two-step process is necessary because when a project is created, it has no followers by default. CircleCI doesn't create webhooks for projects without followers to avoid running unnecessary pipelines that consume credits.

Additional Resources

Did this answer your question?