XSRF Token missing

Paul Nichols January 26, 2014

I'm trying to use jira-python (plus some of my own scripts) to add users to a group. I keep getting an XSRF Token Missing error. I found this https://developer.atlassian.com/display/JIRADEV/Form+Token+Handlingbut my Java knowledge isn't strong enough to figure out how to Pythonize it, if that's even the right way to go.

3 answers

0 votes
Adrien Ragot 2
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 27, 2014

If it tells you the XSRF token is missing, that means you're posting your data as a form. Can you show us the python code you're using for that?

Instead of posting a form, you should try to post json data:

  • Set a header to "application/json"
  • And use json.dump(your_data) to serialize the contents.

The result should be similar to the code sample which is next to the green tick on this page: http://stackoverflow.com/questions/9746303/how-do-i-send-a-post-request-as-a-json

The drawback is, it's up to the JIRA code you're targetting to accept to switch between JSON or forms, so we need to know which url you're targetting.

0 votes
Paul Nichols January 26, 2014

I'm afraid I don't follow what you're asking.

0 votes
Adrien Ragot 2
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 26, 2014

Sorry I'm more expert with Confluence, but XSRF tokens are only useful when you POST a form. If you POST a JSON content, you shouldn't need it. Does it work if you use JSON instead of a form?

For the background knowledge, XSRF tokens only exist because it's possible to post an html form to another website, whereas it wouldn't be possible in Javascript because it would be a cross-site request.

Suggest an answer

Log in or Sign up to answer