XSRF Token missing

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

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.

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

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.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in Jira

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,096 views 0 8
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you