Fax sent from API but status is Sending failed php
Tags: sdk
Jul 12, 2017 at 2:39am • 15 replies • 0 likes
tayyab-sajjad
I am trying to Send Fax from PHP SDK it works and providing a sent URL but after that when i check the status of fax it is sending failed.
15 Answers
Thanks @AK(Anil) for helping.
Now the issue is resolved i was selecting wrong platform.
Now i am using Server No UI and my fax are working fine
Now the issue is resolved i was selecting wrong platform.
Now i am using Server No UI and my fax are working fine
1
Boban J on Mar 2, 2021 at 1:30am • 0 likes
Hi,
I am using "Other Non-UI" but still facing the same issue .Initially i am getting successful response with queued status
Message id: 9134754005
Message status: Queued , ,
Message uri to get status- https://platform.devtest.ringcentral.com/restapi/v1.0/account/290219004/extension/290219004/message-store/9134754005
But after some time getting "SendingFailed" status for all sent messages.
I am Using Ringcentral SDK for C# dot net core POC .
@ak -Please suggest the solution
Tayyab,
I used the same exact code and I created a new extension on your sandbox account just to verify on behalf of your account.
It works fine! For ref: I have created Ext 102
For more information on how the fax is rendered, you could refer to our FAQ below:
Fax FAQ RingCentral
I used the same exact code and I created a new extension on your sandbox account just to verify on behalf of your account.
It works fine! For ref: I have created Ext 102
For more information on how the fax is rendered, you could refer to our FAQ below:
Fax FAQ RingCentral
0
i am getting this response when i check it from api explorer of RC
{ "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/account/207664004/extension/207664004/message-...;, "records": [ { "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/account/207664004/extension/207664004/message-...;, "id": 3244561004, "to": [ { "phoneNumber": "+13129828160", "messageStatus": "SendingFailed", "faxErrorCode": "RenderingFailed" } ], "type": "Fax", "creationTime": "2017-07-12T15:29:42.000Z", "readStatus": "Unread", "priority": "Normal", "attachments": [ { "id": 3244561004, "uri": "https://media.devtest.ringcentral.com/restapi/v1.0/account/207664004/extension/207664004/message-sto...;, "type": "RenderedDocument", "contentType": "application/pdf" } ], "direction": "Outbound", "availability": "Alive", "messageStatus": "SendingFailed", "faxResolution": "High", "faxPageCount": 0, "lastModifiedTime": "2017-07-12T15:36:51.213Z", "coverIndex": 7 },
{ "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/account/207664004/extension/207664004/message-...;, "records": [ { "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/account/207664004/extension/207664004/message-...;, "id": 3244561004, "to": [ { "phoneNumber": "+13129828160", "messageStatus": "SendingFailed", "faxErrorCode": "RenderingFailed" } ], "type": "Fax", "creationTime": "2017-07-12T15:29:42.000Z", "readStatus": "Unread", "priority": "Normal", "attachments": [ { "id": 3244561004, "uri": "https://media.devtest.ringcentral.com/restapi/v1.0/account/207664004/extension/207664004/message-sto...;, "type": "RenderedDocument", "contentType": "application/pdf" } ], "direction": "Outbound", "availability": "Alive", "messageStatus": "SendingFailed", "faxResolution": "High", "faxPageCount": 0, "lastModifiedTime": "2017-07-12T15:36:51.213Z", "coverIndex": 7 },
0
Hi Tayyab,
Your code looks ok and it looks exactly the same as the demo code for PHP SDK.
I just doubt that the number you were trying to sent a fax was the one that cannot receive a fax message (presumed that it was the real number you were sending to!). So I tested sending a fax to that number from my test app and it also failed. Similarly, it failed when I sent a fax to my mobile number. However, the same code would send fax successfully to my RingCentral number or to a real fax number.
Please try again to send fax to a fax machine, or to your other extension number which support fax. You can also try to send to my test number 13129828160
Hope this helps,
Paco
Your code looks ok and it looks exactly the same as the demo code for PHP SDK.
I just doubt that the number you were trying to sent a fax was the one that cannot receive a fax message (presumed that it was the real number you were sending to!). So I tested sending a fax to that number from my test app and it also failed. Similarly, it failed when I sent a fax to my mobile number. However, the same code would send fax successfully to my RingCentral number or to a real fax number.
Please try again to send fax to a fax machine, or to your other extension number which support fax. You can also try to send to my test number 13129828160
Hope this helps,
Paco
1
i am getting this response while sending Fax.
D:\wamp\www\vendor2\ringcentral\ringcentral-php\demo\ authData.php:58:
Every Fax is in Sending failed status after Queued status.
But SMS are sending successfully.
D:\wamp\www\vendor2\ringcentral\ringcentral-php\demo\ authData.php:58:
object(RingCentral\SDK\Http\ApiResponse)[48] protected '_jsonAsArray' => null protected '_jsonAsObject' => null protected '_multiparts' => null protected '_response' => object(GuzzleHttp\Psr7\Response)[46] private 'reasonPhrase' => string 'OK' (length=2) private 'statusCode' => int 200 private 'headers' => array (size=13) 'Server' => array (size=1) ... 'Date' => array (size=1) ... 'Content-Type' => array (size=1) ... 'Content-Length' => array (size=1) ... 'Connection' => array (size=1) ... 'RCRequestId' => array (size=1) ... 'RoutingKey' => array (size=1) ... 'Content-Language' => array (size=1) ... 'Vary' => array (size=1) ... 'X-Rate-Limit-Group' => array (size=1) ... 'X-Rate-Limit-Limit' => array (size=1) ... 'X-Rate-Limit-Remaining' => array (size=1) ... 'X-Rate-Limit-Window' => array (size=1) ... private 'headerNames' => array (size=13) 'server' => string 'Server' (length=6) 'date' => string 'Date' (length=4) 'content-type' => string 'Content-Type' (length=12) 'content-length' => string 'Content-Length' (length=14) 'connection' => string 'Connection' (length=10) 'rcrequestid' => string 'RCRequestId' (length=11) 'routingkey' => string 'RoutingKey' (length=10) 'content-language' => string 'Content-Language' (length=16) 'vary' => string 'Vary' (length=4) 'x-rate-limit-group' => string 'X-Rate-Limit-Group' (length=18) 'x-rate-limit-limit' => string 'X-Rate-Limit-Limit' (length=18) 'x-rate-limit-remaining' => string 'X-Rate-Limit-Remaining' (length=22) 'x-rate-limit-window' => string 'X-Rate-Limit-Window' (length=19) private 'protocol' => string '1.1' (length=3) private 'stream' => object(GuzzleHttp\Psr7\Stream)[44] private 'stream' => resource(66, stream) private 'size' => null private 'seekable' => boolean true private 'readable' => boolean true private 'writable' => boolean true private 'uri' => string 'php://temp' (length=10) private 'customMetadata' => array (size=0) ... protected '_request' => object(GuzzleHttp\Psr7\Request)[37] private 'method' => string 'POST' (length=4) private 'requestTarget' => null private 'uri' => object(GuzzleHttp\Psr7\Uri)[21] private 'scheme' => string 'https' (length=5) private 'userInfo' => string '' (length=0) private 'host' => string 'platform.devtest.ringcentral.com' (length=32) private 'port' => null private 'path' => string '/restapi/v1.0/account/~/extension/~/fax' (length=39) private 'query' => string '' (length=0) private 'fragment' => string '' (length=0) private 'headers' => array (size=6) 'Host' => array (size=1) ... 'Content-Type' => array (size=1) ... 'Authorization' => array (size=1) ... 'User-Agent' => array (size=1) ... 'RC-User-Agent' => array (size=1) ... 'Expect' => array (size=1) ... private 'headerNames' => array (size=6) 'content-type' => string 'Content-Type' (length=12) 'authorization' => string 'Authorization' (length=13) 'user-agent' => string 'User-Agent' (length=10) 'rc-user-agent' => string 'RC-User-Agent' (length=13) 'host' => string 'Host' (length=4) 'expect' => string 'Expect' (length=6) private 'protocol' => string '1.1' (length=3) private 'stream' => object(GuzzleHttp\Psr7\MultipartStream)[22] private 'boundary' => string 'de8542ac0534cffa01ee24f9f9d509f1a6770ea3' (length=40) public 'stream' => object(GuzzleHttp\Psr7\AppendStream)[23]...
Every Fax is in Sending failed status after Queued status.
But SMS are sending successfully.
0
Could you please also provide the detailed content of $response = $platform->sendRequest($request); ? Are there any exceptions? If so, please post them.
I have to go offline now because it's out of my working hours. We have several Developer Relationship Engineers in different timezones and others will continue to respond.
I have to go offline now because it's out of my working hours. We have several Developer Relationship Engineers in different timezones and others will continue to respond.
0
0
<?php
require_once(' _bootstrap.php');
use RingCentral\SDK\SDK;
// Create SDK instance
$credentials = require(' _credentials.php');
$rcsdk = new SDK('', '', ' https://platform.devtest.ringcentral.com', 'app1', '1.0.0');
$platform = $rcsdk->platform();
// Retrieve previous authentication data
$cacheDir = __DIR__ . DIRECTORY_SEPARATOR . '_cache';
$file = $cacheDir . DIRECTORY_SEPARATOR . 'platform.json';
if (!file_exists($cacheDir)) {
mkdir($cacheDir);
}
$cachedAuth = array();
if (file_exists($file)) {
$cachedAuth = json_decode(file_get_contents($file), true);
unlink($file); // dispose cache file, it will be updated if script ends successfully
}
$platform->auth()->setData($cachedAuth);
try {
$platform->refresh();
$request = $rcsdk->createMultipartBuilder()
->setBody(array(
'to' => array(
array('phoneNumber' => '12673314004'),
),
'faxResolution' => 'High',
))
->add('Plain Text', 'file.txt')
->add(fopen('D:/wamp/www/vendor/ringcentral/ringcentral-php/demo/file.txt', 'r'))
->request('/account/~/extension/~/fax'); // also has optional $method argument
$response = $platform->sendRequest($request);
print 'Sent Fax ' . $response->json()->uri . PHP_EOL;
print 'Authorization was restored' . PHP_EOL;
} catch (Exception $e) {
print 'Auth exception: ' . $e->getMessage() . PHP_EOL;
$auth = $platform->login($credentials['username'], $credentials['extension'], $credentials['password']);
print 'Authorized' . PHP_EOL;
}
// Save authentication data
file_put_contents($file, json_encode($platform->auth()->data(), JSON_PRETTY_PRINT));
require_once(' _bootstrap.php');
use RingCentral\SDK\SDK;
// Create SDK instance
$credentials = require(' _credentials.php');
$rcsdk = new SDK('', '', ' https://platform.devtest.ringcentral.com', 'app1', '1.0.0');
$platform = $rcsdk->platform();
// Retrieve previous authentication data
$cacheDir = __DIR__ . DIRECTORY_SEPARATOR . '_cache';
$file = $cacheDir . DIRECTORY_SEPARATOR . 'platform.json';
if (!file_exists($cacheDir)) {
mkdir($cacheDir);
}
$cachedAuth = array();
if (file_exists($file)) {
$cachedAuth = json_decode(file_get_contents($file), true);
unlink($file); // dispose cache file, it will be updated if script ends successfully
}
$platform->auth()->setData($cachedAuth);
try {
$platform->refresh();
$request = $rcsdk->createMultipartBuilder()
->setBody(array(
'to' => array(
array('phoneNumber' => '12673314004'),
),
'faxResolution' => 'High',
))
->add('Plain Text', 'file.txt')
->add(fopen('D:/wamp/www/vendor/ringcentral/ringcentral-php/demo/file.txt', 'r'))
->request('/account/~/extension/~/fax'); // also has optional $method argument
$response = $platform->sendRequest($request);
print 'Sent Fax ' . $response->json()->uri . PHP_EOL;
print 'Authorization was restored' . PHP_EOL;
} catch (Exception $e) {
print 'Auth exception: ' . $e->getMessage() . PHP_EOL;
$auth = $platform->login($credentials['username'], $credentials['extension'], $credentials['password']);
print 'Authorized' . PHP_EOL;
}
// Save authentication data
file_put_contents($file, json_encode($platform->auth()->data(), JSON_PRETTY_PRINT));
0
A new Community is coming to RingCentral!
Posts are currently read-only as we transition into our new platform.We thank you for your patience
during this downtime.
Try Workflow Builder
Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!Try RingCentral Workflow Builder