首页 > 解决方案 > 在 R 中使用 REST API 向 JIRA 问题单添加评论

问题描述

我想从 R 以编程方式使用 REST API 向现有 JIRA 票证添加更多评论

我根据此论坛中的链接尝试了以下操作,但没有成功:

library(httr)

POST("https://xxxxxx.atlassian.net/rest/api/2/issue/issueId/comment",body = "New Comment", authenticate(userid,password, "basic"))

标签: r

解决方案


我在您的论坛链接中检查了接受的答案,它建议使用以下 POST curl

curl -u admin:admin -X POST --data '{"body": "comment."}' -H "Content-type: application/json" http://localhost:2990/jira/rest/api/2 /issue/TEST-1/comment

请注意,正文是 JSON 内容,内容类型也设置为 JSON。您可以尝试在POST()从以下位置调用函数时执行相同的操作httr

POST("https://xxxxxx.atlassian.net/rest/api/2/issue/issueId/comment",
    body = '{"body": "comment."}', authenticate(userid, password, "basic"),
    encode="raw")

推荐阅读