i am trying to create a webhook from one of my applications in php using curl
here is the piece of code i am using (my token is correct and i own the 6642490389358468 sheet)
function setWebHook($token){
// API Url
// BASE_API_URL = "https://api.smartsheet.com/2.0/";
$url = self::BASE_API_URL. "webhooks";
$headers = array(
"Authorization: Bearer ". $token,
"Content-Type: application/json"
);
//The JSON data.
$jsonData = array(
"callbackUrl"=>"https://www.example.com/myapp/test",
"scope"=>"sheet",
"scopeObjectId"=>6642490389358468,
"version"=>1,
"events"=>[ "*.*" ]
);
//Initiate cURL.
$ch = curl_init($url);
//Encode the array into JSON.
$jsonDataEncoded = json_encode($jsonData);
//Tell cURL that we want to send a POST request.
curl_setopt($ch, CURLOPT_POST, 1);
//Attach our encoded JSON string to the POST fields.
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
//Set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
//Execute the request
$result = curl_exec($ch);
if (curl_errno($ch)) {
$apiResponse = "Oh No! Error: " . curl_error($ch);
} else {
// Assign response to variable
$apiResponse = json_decode($result);
curl_close($ch);
}
return $apiResponse;
}
but i get the following response
{
"errorCode": 1004,
"message": "You are not authorized to perform this action.",
"refId": "x2kcvthuyfs8"
}
can you help me troubleshoot that? am i missing somehing?