Question

It seems that JIRA REST API v 4.4 doesn't allow comment creation. At least I can't find the documentation and a POST to /issue//comment doesn't work. So I tried mimicking the same post the browser does when a user enters a comment manually. It doesn't work either, this is the error I'm getting:

XSRF Security Token Missing - Numerex JIRA

I'm passing the alt_token id and the jsession id apparently correctly. I'm using HTTParty to make the request, and I'm not sure the headers are passing as they should (I'm using Firefox Live HTTP Headers to view the exact headers). Is there a way of checking what headers is HTTParty exactly sending? I'm using the :headers option to pass my headers but I don't know what is really being sent to the server.

Was it helpful?

Solution

This is the code that allowed me to create the issue comment. It makes use of the web interface because v4.4 REST API doesn't provide issue comment creation.

response = self.class.post(url, :headers => @set_cookie. merge({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Atlassian-Token' => 'no-check'}), :body => post_data)

@set_cookie is a variable loaded with set-cookie response from the first request to the system. post_data contains the url encoded form data with the comment, ticket id and other parameters.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top