Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

xsrf check failed creating project bitbucket server using python request

Hi Team,

I'm trying to create a project using a python script and the requests library.

When doing get requests, I have no problem, but when doing post requests, I encounter a "xsrf check failed"

Here's the snippet:

payload = {"key":"EQSS_TST", "name":"qtm_test"}

r ='', params=payload, auth=(user,password))

The error message is "XSRF check failed"

Thanks for you help!


3 answers

The POST request header must contain Content-type = application/json 

I'm not planning on adding an avatar to the project so I shouldn't need to define the content-type.

The example prototype on the documentation says:

    "key": "PRJ",
    "name": "My Cool Project",
    "description": "The description for my cool project.",
    "avatar": "data:image/png;base64,<base64-encoded-image-data>"

Has anybody ever created a project using the "requests" python library?

I've had a similar issue with posting comments through, and it solved with adding the following lines to the header:

 'x-atlassian-token': 'no-check',
'x-requested-with': 'XMLHttpRequest',

 So the session object looks as follows:

s = requests.Session()
s.auth = auth
s.verify = False

s.headers = {
'origin': '',
'pragma': 'no-cache',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 YaBrowser/ Yowser/2.5 Safari/537.36',
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
'referer': '',
'x-atlassian-token': 'no-check',
'x-requested-with': 'XMLHttpRequest',

and response object looks as:

r =
params = params,
data = data,


WEB = ''

params = {'actions':'true'}

data = {
'html': '<p>Test</p>',
'watch': 'false',
'uuid': '54b022eb-e098-a3ad-5f8d-fd68619681fb'


Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,892 views 0 7
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you