XSRF Security Token Missing when trying to post a form with e.g. curl or python

Hi,

we have a python script that recursively checks all projects/repositories for a checked "allow forks" setting.

The get request works without any problem.

But when we try to switch off "allow forks" with a post request an error "XSRF Security Token Missing" occurs.

For debugging purposes we crosschecked this behaviour using curl. Same problem here.

Our curl command (servername removed):

curl -vs --insecure -H "Content-Type: application/json" -H "X-Atlassian-Token: no-check" -X POST -d '{"name":"bitbucket","forkable":"off"}' https://servername.domain.de:8443/projects/XXX/repos/bitbucket/settings

Output (security relevant information removed)

 About to connect() to servername.domain.de port 8443 (#0)
Trying ip_here...
Connected to servername.domain.de (ip_here) port 8443 (#0)
Initializing NSS with certpath: sql:/etc/pki/nssdb
skipping SSL peer certificate verification
SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
Server certificate: **removed**
POST /projects/XXX/repos/bitbucket/settings HTTP/1.1
User-Agent: curl/7.29.0
Host: servername.domain.de:8443
Accept: */*
Content-Type: application/json
X-Atlassian-Token: no-check
Content-Length: 37

and lots of HTML output containing the error "XSRF Security Token Missing" somewhere inside.

We also tried passing the -u 'username' parameter and the password along woth the curl command - same result.

All the documentation found in the web results in using the

X-Atlassian-Token: no-check

in the header information. It doesn'n matter if I use nocheck or no-check.

Any idea how to solve this?

Thanks & regards

Peter

1 answer

0 vote
Josh Steckler Community Champion Jul 14, 2017

Are you missing /rest/api/1.0 in your URL?

Hi Josh,

 

thanks for your hint. I already tried this

curl -vs --insecure -H "Content-Type: application/json" -H "X-Atlassian-Token: no-check" -H "Origin: https://SERVERNAME.tui.de:8443" -X POST -d '{"name":"bitbucket","forkable":"off"}' -u BITBUCKETUSER https://SERVERNAME:8443/rest/api/1.0/projects/SCM/repos/bitbucket/

I get the following error:

This repository URL is already taken by 'bitbucket' in 'Systemuser Bitbucket'"

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

711 views 0 4
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot