github - 使用 GitHub API 将降价表作为 Pull Request 评论发布到 GitHub
问题描述
我可以使用 API 将文本发布到 GitHub 上的拉取请求
https://api.github.com/repos/aftab-hassan/pagerankassignment/pulls/2/comments
并使用以下作为主体
{
"body": "Nice change",
"commit_id": "5dfc67045edc45ed102f6bf6ad0c1209fdd2ef38",
"path": "README",
"position": 4
}
我正在尝试发布一个如下的降价表作为正文而不是上面的纯文本。
First Header | Second Header
------------ | -------------
Content from cell 1 | Content from cell 2
Content in the first column | Content in the second column
但是,它给了我如下错误
{
"message": "Problems parsing JSON",
"documentation_url": "https://developer.github.com/v3/pulls/comments/#create-a-comment"
}
我确实尝试将正文类型更改为文本而不是 json。我还尝试将\n
s 添加到降价正文,因为它跨越多行。但是,这些尝试似乎都不起作用,并且给了我与上述相同的错误。
{
"body": "First Header | Second Header\n
------------ | -------------\n
Content from cell 1 | Content from cell 2\n
Content in the first column | Content in the second column",
"commit_id": "5dfc67045edc45ed102f6bf6ad0c1209fdd2ef38",
"path": "README",
"position": 4
}
如何通过 Postman 在 GitHub 上发布降价表作为对拉取请求的评论?
解决方案
您的 JSON 字符串应该只包含转义的换行符,而不是文字的换行符。所以body
变成
"First Header | Second Header\n------------ | -------------\nContent from cell 1 | Content from cell 2\nContent in the first column | Content in the second column"
查看此答案,以更灵活地处理 JSON 的任意输入。
推荐阅读
- sql - SqlBeautifier:如何更改 super+k super+f 键绑定?
- woocommerce - 为什么 wc_get_template_part() 在 wc_get_products() 中不起作用?
- xamarin - 如何在xamarin的collectionview中绑定嵌套列表项
- html - 如何使我的收音机、复选框和文本区域输入响应?
- javascript - 在 Todo 应用 Redux 中创建删除函数时出错:TypeError: state.byIds.filter 不是函数
- javascript - 尝试将canvacord部署到herkou时出错
- c - 如何从 char* 填充 C 结构并分配额外的内存
- go - Kubernetes `client-go` - 如何在 pod 中获取容器状态
- python - python sdk资源组
- riscv - 如何在 RISC-V 中实现睡眠实用程序?