Hi
I have problem with API key. I have tried PHP and Python code's but every time I get same error. I want to get sheet row ID's.
This is my PHP code:
<?php
$apiKey = "API_KEY"; // in my code I replace it with real API key
$sheetID = 4969625754404740;
$apiUrl = "https://api.smartsheet.com/2.0/sheets/$sheetID";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Authorization: Bearer $apiKey",
"Content-Type: application/json"
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo "CURL Error: " . curl_error($ch);
}
echo $response;
if ($response) {
$data = json_decode($response, true);
if (isset($data["columns"])) {
echo "Columns in the sheet:\n";
foreach ($data["columns"] as $column) {
echo "Name: " . $column["title"] . ", ID: " . $column["id"] . "\n";
}
} else {
echo "No columns found in the sheet.";
}
} else {
echo "Failed to retrieve data from Smartsheet.";
}
?>
And this is error what I get:
{ "errorCode" : 1002, "message" : "Your Access Token is invalid.", "refId" : "sphoti" }No columns found in the sheet.
I have generated 5-6 different API keys (for now I am deleted some) and every time same result. What I am doing wrong?