Using Github APIv3 Create PR with Head as a CommitSHA

In the list of inputs, I am able able to specify the Head as a Commit from which I want to create the PR. 

https://developer.github.com/v3/pulls/#input

{
“title”: "PR Created for Merging Head: relfix/wip-branch3 to Base: release ",
“body”: “PR Created using Github API”,
“head”: “assfds12XXXXXXXXXXXXXXXXXXXXXXXXX”,
“base”: “relase”
}

I am trying to do this in Powershell. Is there a way possible to do that? Whenever I try to use SHA instead of a branch name in Head, I get this Error:-

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

The documentation you reference specifically states that the head field must be the name of a branch, not a SHA. So if you want to create a pull request using a given SHA, you’ll have to create a branch there first.

I hope that helps. Let us know if you have more questions.