raliqala
raliqala

Reputation: 164

Twilio Uncaught Twilio\Exceptions\RestException: [HTTP 401] Unable to fetch record:

Am trying to Fetch a Queue resource on twilio i want to get the current_size (queue size)

am using PHP code below


use Twilio\Rest\Client;

$sid    = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$token  = "your_auth_token";
$twilio = new Client($sid, $token);

$queue = $twilio->queues("QUXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                ->fetch();

print($queue->friendlyName);

but i keep getting this error

Fatal error: Uncaught Twilio\Exceptions\RestException: [HTTP 401] Unable to fetch record: Authentication Error - invalid username in C:\xampp\htdocs\calls\vendor\twilio\sdk\src\Twilio\Version.php:86 Stack trace: #0 C:\xampp\htdocs\calls\vendor\twilio\sdk\src\Twilio\Version.php(111): Twilio\Version->exception(Object(Twilio\Http\Response), 'Unable to fetch...') #1 C:\xampp\htdocs\calls\vendor\twilio\sdk\src\Twilio\Rest\Api\V2010\Account\QueueContext.php(51): Twilio\Version->fetch('GET', '/Accounts/AP726...') #2 C:\xampp\htdocs\calls\agent\incoming.php(22): Twilio\Rest\Api\V2010\Account\QueueContext->fetch() #3 {main} thrown in C:\xampp\htdocs\calls\vendor\twilio\sdk\src\Twilio\Version.php on line 86

any solution how to fix this? and or get the current queue size

Please help.

Thanks in advance

Upvotes: 1

Views: 6195

Answers (1)

TTA
TTA

Reputation: 66

Are you able to successfully execute a curl query from the Twilio API explorer, or from your machine to fetch the same information?

https://www.twilio.com/console/api-explorer/voice/queues/read

This error seems to be caused by passing an invalid SID.

Upvotes: 3

Related Questions