createPullRequest API not working

Hey, I’ve added to my query everything that you indicated a need for in the docs for the GraphQL API’s createPullRequestInput, but I’m still getting the following errors:

[data:[createPullRequest:[pullRequest:null]], errors:[[type:UNPROCESSABLE, path:[createPullRequest], locations:[[line:3, column:7]], message:Head sha can't be blank, Base sha can't be blank, No commits between master and CICD-3853_test_branch, Head ref must be a branch]]]

Here’s my code for reference:

// query
    mutation createPrForArns {
      createPullRequest(input:{ baseRefName: "master", body: "my test PR body", headRefName: "my-feature-branch", repositoryId: "my-repo-node-id", title: "test" }) {
        pullRequest {
          resourcePath
        }
      }
    }

Any help around this would be highly appreciated.

P.S. It would be really helpful to have examples for the mutations in your API documentation. Thanks.

By the way, there is a commit between the testing branch and the base branch of master - I added a test commit and pushed it up to the testing branch. 

@cjiang-ias 

This is working fine for me.

What is the error message that you are getting?

Also, is your testing branch pushed to the origin or it is a local branch?

mutation {
	createPullRequest(input: {
		repositoryId: "X-X-X-X",
		baseRefName: "master",
		title: "Pull request from github V4",
		headRefName: "parithibang-patch-3"
	}) {
		pullRequest {
			body
			title
		}
	}
}

1 Like

Thanks for following up, @parithiban. Turns out it was just the wrong repo ID. The mutation indeed works. 

1 Like

Thanks for sharing, works fine.