Sebi
Sebi

Reputation: 3979

Jira v.6.2 : Add comment to issue via C# WebRequest

I need to add a comment to an issue from c#. I read some article in jira api and so on but i still get a bad response (400).

This is the code i tried so far:

        string url = @"http://jira-test.ourcompany.de/rest/api/2/issue/" +
                     "IT-20175/comment?{\"body\":\"Test123\"}";

        WebRequest wrUrl = WebRequest.Create(url);
        wrUrl.ContentType = "application/json";
        wrUrl.Method = "POST";
        wrUrl.Headers["Authorization"] = "Basic " + Convert
            .ToBase64String(Encoding.ASCII.GetBytes(AuthInfo));            
        wrUrl.Method = "POST";

        Stream stream = wrUrl.GetResponse().GetResponseStream();

This should add a comment "Test123" to issue IT-20175. But it doesnt work. Maybe someone can find my mistake?

regards

Upvotes: 0

Views: 1483

Answers (1)

mp911de
mp911de

Reputation: 18137

You have to put the comment JSON into your POST request body, not within the URL

URL: http://jira-test.ourcompany.de/rest/api/2/issue/IT-20175/comment

Body: {"body":"Test123"}

Upvotes: 1

Related Questions