如何使用Rest API向Jira问题添加评论

问题描述:

在nuget包中找到了AnotherJiraClient代码

Refered AnotherJiraClient code found in nuget package

已引用此 https://developer.atlassian.com/display/JIRADEV/JIRA + REST + API + Example +-+ Add + Comment 添加评论.

Refered this https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Add+Comment to add a comment.

    var request = new RestRequest()
    {
        Resource = ResourceUrls.Comment(),
        RequestFormat = DataFormat.Json,
        Method = Method.POST
    };
    request.AddBody(addComment);//{"body":"Something"}

    return Execute<BasicIssue>(request, HttpStatusCode.Created);

但是总是以未找到状态返回吗? 如何使用Jira REST API添加评论?

But always returned with status not found? How to add comments using Jira REST API?

我弄清楚我在代码中输入了什么.我需要将注释作为json对象提供.

I figured out what was I mssing in the code. I need to provide the comment as an json object.

library(httr)
library(RJSONIO)

x <- toJSON(list(body = "Adding a new Comment"))

POST("https://xxxxxx.atlassian.net/rest/api/2/issue/{issueIdOrKey}/comment",body = x, authenticate(userid,password, "basic"), add_headers("Content-Type" = "application/json"), verbose())