我尝试使用v3 GitHub API在该行上创建评论。 Rhe文档说明如下:
注意:要评论文件中的特定行,您需要首先确定diff中该行的位置。 GitHub REST API v3提供application / vnd.github.v3.diff媒体类型。要查看拉取请求差异,请将此媒体类型添加到对单个拉取请求端点的调用的Accept标头中。
Link到文档。但当我尝试提出请求时,它会回复:
<form method='post'>
<input name='field_name' style='display:none' value='abc'>
<input type='submit' value='submit'>
</form>
API并没有向我展示差异。
请求示例:
[
{
"sha": "7ed12345678911cd0d8c6bf34fa547aaa6eab5b6",
"filename": "README.md",
"status": "modified",
"additions": 1,
"deletions": 1,
"changes": 2,
"blob_url": "https://github.com/johnsnow/demo/blob/37422b7241b0dadcdac1af53f8e33baba7b489bd/README.md",
"raw_url": "https://github.com/johnsnow/demo/raw/37422b7241b0dadcdac1af53f8e33baba7b489bd/README.md",
"contents_url": "https://api.github.com/repos/johnsnow/demo/contents/README.md?ref=37422b7241b0dadcdac1af53f8e33baba7b489bd",
"patch": "@@ -1,6 +1,6 @@\n # Application model for Java 8\n \n-We provide a basic model for JDK 1.8 / Spark based web applications.\n+AWe provide a basic model for JDK 1.8 / Spark based web applications."
}
]
答案 0 :(得分:1)
让我们仔细看看您引用的文档中的最后一句:
要查看拉取请求差异,请将此媒体类型添加到对single pull request端点的调用的Accept标头中。
但是您要求"List pull requests files" endpoint。从请求网址末尾删除/files
:
curl -X GET \
'https://api.github.com/repos/johnsnow/demo/pulls/20?access_token=some_token' \
-H 'Accept: application/vnd.github.v3.diff'