question

justin-nahin avatar image
justin-nahin asked ·

method not allowed

I am getting this error of "Method Not Allowed" when trying to retrieve the call logs through PHP.

RingCentral API Error ->  Method Not Allowed

Any Ideas?

$call_log_url = '/account/~/extension/~/call-log';
$ref = &$this->connection->platform;

try {
    $apiResponse = $ref->post($call_log_url);
// dd($apiResponse);
}
catch (\RingCentral\SDK\Http\ApiException $e) {
echo 'RingCentral API Error -> <b>' . $e->getMessage() . '</b>';
}
topic-default
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

ak avatar image
ak answered ·
Hi Justin,

You should be using a GET request instead of a POST request in order to retrieve call logs through the API.

Please have a look at the code below :

try {
                  
    
$apiResponse = $platform->get('/account/~/extension/~/call-log', array(
'perPage' => 10
));
print 'Retreieved Call logs' . $apiResponse->json()->uri . PHP_EOL;
} catch (\RingCentral\SDK\Http\ApiExceptionHttpException $e) {
    echo 'RingCentral API Error -> <b>' . $e->getMessage() . '</b>';
}

1 comment Share
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Wow, thanks so much Anil!  Was stuck on this one for days.
0 Likes 0 · ·
Anirban Sen Chowdhary avatar image
Anirban Sen Chowdhary answered ·

This is a general kind of mistake every developers does now and then. It we hit an API with wrong method type eg hit GET method in API where the API expect POST and vice versa, this Method Not Allowed occurs.

Reading the full documentation is required in this case

Share
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.