Search code examples
githubgithub-apigithub-app

Unable to create project in repository or organisation using GitHub REST API


I am trying to create a project in a GitHub repository using the GitHub REST APIs. I have installed a GitHub app and am using the octokit library and nodejs is my programming language. I have configured the app and given it all the necessary permissions to read/write projects, repositories etc. For repositories, i have enabled Repository feature settings

I am able to list the repositories, branches etc successfully, but i am not able to list the projects neither am I able add any project to any of the repositories. I read in the notes that project can only be added if a project already exists in the repository. But even that has not worked. My code is as below

for await (const { octokit, installation } of app.eachInstallation.iterator()) { 
  const result = await octokit.request('POST /repos/{owner}/{repo}/projects', {
    owner: owner,
    repo: repo,
    name: projectName
  });
  console.log("Project: ", result.data.name)
}

When i run this code, i get an error with message that "Projects are disabled for this repository".

data: {
  message: 'Projects are disabled for this repository',
  documentation_url: 'https://docs.github.com/v3/projects'
}

Solution

  • So after looking around this is what i have found

    1. The API no longer supports working with the new set of Projects. It only supports classic projects
    2. Classic projects can no longer be created in GitHub
    3. Thankfully, Github provides another approach, which is GraphQL
    4. Using graphql you can perform all operations on the Projects, repositories etc Refer to the page https://docs.github.com/en/graphql/reference/mutations for more information