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

Php confluence api

Sampath Mallidi January 5, 2017

HI,

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

 

$url = "https://xxxxxxx.atlassian.net/rest/api/space?spaceKey=xxx";
 
$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;
 
}  
 
curl_close($ch);

 

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

1 answer

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 6, 2017

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.

Sampath Mallidi January 8, 2017

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

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 9, 2017

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.

abbasalis September 26, 2017

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

Alexander Sloan October 25, 2018

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
TAGS
AUG Leaders

Atlassian Community Events