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"}
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 ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Same issue. The token is definitely fine, it's from my user and I'm a global admin.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.