Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a simple pull request results in 422 Validation error #1943

Closed
shahabhijeet opened this issue Feb 20, 2019 · 6 comments
Closed

Creating a simple pull request results in 422 Validation error #1943

shahabhijeet opened this issue Feb 20, 2019 · 6 comments

Comments

@shahabhijeet
Copy link
Contributor

shahabhijeet commented Feb 20, 2019

I am using octokit.net 0.32.0 nuget pacakge in my .NET Standard 2.0 library
Here is my code

GitHubClient ghClient = new GitHubClient(new ProductHeaderValue("mylibName", "myLibVersion"));
ghClient.Credentials = new Credentials(apiToken);

NewPullRequest newPr = new NewPullRequest("Myfirstpr", "branchNameInMyFork", "master");

GitHubClient.PullRequest.Create(RepoId, newPr);
I get Status: 422 Unprocessable Entity (Validation Error)
X-GitHub-Request-Id: 80AC:9603:39B8FB:45A1F7:5C6CAE6E

GitHubClient.PullRequest.Create("ownerName", "myRepoName", newPr);
I get Status: 422 Unprocessable Entity (Validateion Error)
X-GitHub-Request-Id: CC45:95FF:1535CF:19BA38:5C6CB540

Can you provide me a working example that will allow me to create a Pull Request?
I don't seem to find any examples that will show me how to create a simple pull request.

@shahabhijeet shahabhijeet changed the title Creating a simple pull request results in 422/404 errors Creating a simple pull request results in 422 Validation error Feb 20, 2019
@shiftkey
Copy link
Member

@shahabhijeet my best guess is that you're not using the right value for the head parameter. If it's coming from a fork, the head parameter needs to be of the format username:branch.

@shahabhijeet
Copy link
Contributor Author

@shiftkey I was able to get more details, now I get this

{"message":"Validation Failed","errors":[{"resource":"PullRequest","field":"base","code":"invalid"}],"documentation_url":"https://developer.github.com/v3/pulls/#create-a-pull-request"}

And so far I have tried the format for base as
organizationName:master
organizationName/repositoryName:master
RepositoryName:master

nothing seems to work.

So what would be good to know is, if I had to create a pull request from my fork against octokit master branch, what are the values I should be using for head and base
is it
Head ==> shahabhijeet:branchName
Base ==> octokit:master or octokit/octokit.net:master or octokit.net:master

@shahabhijeet
Copy link
Contributor Author

@ryangribble is creating a PullRequest from user fork supported?
If yes would be great to get a sample on how to create a PR. Appreciate your help.

@shahabhijeet
Copy link
Contributor Author

Got it working the following worked for me
If I am creating a PR from my fork (shahabhijeet) and branch (bugFix) against octokit.net master branch

NewPullRequest newPr = new NewPullRequest("Myfirstpr", "shahabhijeet:bugFix", "master")

@hnrkndrssn
Copy link
Contributor

Should this issue be closed as the sample for the docs has been added?

@ryangribble
Copy link
Contributor

Good catch, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants