2

I am using below query to create repo:

   gh api -i graphql -f query='
   mutation {
   createRepository(input: {name: "gh-create-test", visibility: PRIVATE, ownerId: "ID"}) {
    repository {
      url
    }
  }
}
'

THe repo gets created successfully but without admin rights whereas when I create repo from GITHUB UI the repo has admin rights. Can anyone please help what's the issue in this query?

2
  • what do you mean by admin right Commented Aug 4, 2021 at 14:20
  • By admin rights I mean , I don’t see the settings tab for the repo which is created by graphql api but same is visible when created via gui. Commented Aug 4, 2021 at 14:25

1 Answer 1

2

I just created one, Make sure you are getting the id first and pass it to the createRepository

query{
  repositoryOwner(login:"yourLoginId"){
    id
    login
    repositories(first:1) {
      edges {
        node {
          id
        }
      }
    }
  }
}

and create a repository by passing the ownerid

mutation {
   createRepository(input: {name: "gh-create-test", visibility: PRIVATE, ownerId: "idobtainedabove"}) {
    repository {
      url
    }
  }
}
Sign up to request clarification or add additional context in comments.

11 Comments

“yourloginid” what Id is expected here? Github login ?
Error: ``` { "data": { "createRepository": null }, "errors": [ { "type": "FORBIDDEN", "path": [ "createRepository" ], "extensions": { "saml_failure": false }, "locations": [ { "line": 3, "column": 3 } ], "message": "Resource not accessible by integration" ```
But i can create repos from GUI with proper permissions why this is not working with cli?
It works fine for me. Are you trying to do this within an organization?
Yes I am trying for an org
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.