如何使用github API创建github pull请求



我已经将回购的一些更改推送到github上的新分支copyright_updater。更改在github上。

现在我想创建一个pull请求。我一直在看API文档,并想出了以下命令来创建一个pull请求:

curl 
-X POST 
-H "Accept: application/vnd.github.v3+json" 
"https://api.github.com/repos/alex4200/hello-world/pulls" 
-d '{"head":"copyright_updater","base":"master"}' 

但是,这会返回输出

{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest/reference/pulls#create-a-pull-request"
}

那么这次我错过了什么呢?

第页。S.看起来这不是授权问题。即使是象征性的,我也会得到同样的回复。

看起来并不是授权问题。

也许不会,但由于您的代码显示没有授权,我不希望它做任何事情。我能让它正常工作,就像这样:

curl --location --request POST 'https://api.github.com/repos/mattneub/temp/pulls' 
--header 'Authorization: Bearer 55...42' 
--header 'Content-Type: application/json' 
--data-raw '{
"base":"main",
"head":"what",
"title":"Fun"
}'

显然,标题是必需的,即使文件没有这么说。

您将URL放在""中,但文档中没有。尝试:

curl 
-X POST 
-H "Accept: application/vnd.github.v3+json" 
https://api.github.com/repos/alex4200/hello-world/pulls 
-d '{"head":"copyright_updater","base":"master"}' 

最新更新