question

justin-nahin111 avatar image
justin-nahin111 asked Anirban answered

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>';
}      
getting started
1 |3000

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 justin-nahin111 commented
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
1 |3000

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

justin-nahin111 avatar image justin-nahin111 commented ·
Wow, thanks so much Anil!  Was stuck on this one for days.
0 Likes 0 ·
Anirban avatar image
Anirban 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

1 |3000

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

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys