Php confluence api


iam using rest api to get spaces list from confluence using php curl . But iam getting the error .please check my code


$url = "";
$ch = curl_init();
$headers = array(
    'Accept: application/json',
    'Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxx'        // this is the oauth token
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");

curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
$ch_error = curl_error($ch);
if ($ch_error) {
    echo "cURL Error: $ch_error";
} else {
    echo $result;


Response is {"error": "Failed to parse Connect Session Auth Token"}

1 answer

0 votes

The token is incorrect, you'll need to fix that.  It's the Authorisation line, but I can't tell you what's wrong with it as I don't know what php does with it exactly.

Replaced my original token with xxxxxx for security purpose . Can you please show me the example on how to use authorisation line ?

I am sorry, I was not clear.  I had assumed the xxx were obscuring the actual data.  What I'm trying to say is that there is something wrong with the token in there.  I can't tell you whether it's a bad token because I don't know how you've generated, or if it is something php is doing with it that makes it broken for Confluence.

Hi Sampath, if you have fixes for this issue... Please share... I am also facing the same problem...

Same issue. The token is definitely fine, it's from my user and I'm a global admin.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 12, 2019 in Confluence

Confluence Admin Certification now $150 for Community Members

More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...

1,040 views 2 13
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