422 Unprocessable Entity
レスポンスが返される。
レスポンスボディには "Validation Failed" ないし "A pull request already exists for USER:BRANCH." という内容が含まれており、同じ head:base が指定された Pull Request を複数作ることはできない。
逆に言うと、 Pull Request 作成 API は冪等なので、重複を心配せず常に POST しても構わない、とも言える。ただし、公式 API ドキュメントに記載されていないので、予告無く変更されるかもしれない。利用する場合は自己責任で。
https://developer.github.com/v3/pulls/#create-a-pull-request
$ curl -i -H "Authorization: token $token" -d '{"title":"pr_test","head":"pr_test","base":"master"}' https://api.github.com/repos/kyanny/test/pulls
HTTP/1.1 422 Unprocessable Entity
Server: GitHub.com
Date: Sat, 17 May 2014 13:41:36 GMT
Content-Type: application/json; charset=utf-8
Status: 422 Unprocessable Entity
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4993
X-RateLimit-Reset: 1400334277
X-OAuth-Scopes: repo
X-Accepted-OAuth-Scopes:
X-GitHub-Media-Type: github.v3
X-XSS-Protection: 1; mode=block
X-Frame-Options: deny
Content-Security-Policy: default-src 'none'
Content-Length: 281
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
Access-Control-Allow-Origin: *
X-GitHub-Request-Id: 6E86961F:522B:5CED2CE:53776710
Strict-Transport-Security: max-age=31536000
X-Content-Type-Options: nosniff
{
"message": "Validation Failed",
"documentation_url": "https://developer.github.com/v3/pulls/#create-a-pull-request",
"errors": [
{
"resource": "PullRequest",
"code": "custom",
"message": "A pull request already exists for kyanny:pr_test."
}
]
}