News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
PHP SDK Fax Permission Error
Tags: sdk
Apr 15, 2019 at 7:44am   •   7 replies  •  0 likes
nathan-cfd

First time writing an integration using RC's PHP SDK. Installed SDK via Composer and setup the credentials/sandbox, etc. Authorization is fine, app is communicating. Started with the demo/fax.php to test using file.txt (using demo installed with sdk) and I'm getting "Bad Request" but no error code.

I haven't changed anything in the SDK (other than the /path/to/vendor/autoload which is incorrect in _bootstrap)

How can I get more info so I can troubleshoot?

Here's what I'm getting back from RC:

--952ed22a92fb817145143eb568f4a4c84ce5a37b
Content-Type: application/json
Content-Disposition: form-data; name="json"; filename="request.json"
Content-Length: 61

{"to":[{"phoneNumber":"17474773958"}],"faxResolution":"High"}
--952ed22a92fb817145143eb568f4a4c84ce5a37b
Content-Type: application/octet-stream
Content-Disposition: form-data; name="file.txt"; filename="file.txt"
Content-Length: 10

Plain Text
--952ed22a92fb817145143eb568f4a4c84ce5a37b
Content-Disposition: form-data; name="ico_case_crm.png"; filename="ico_case_crm.png"
Content-Type: image/png

<html>
<head>
<META NAME="robots" CONTENT="noindex,nofollow">
<script src="/_Incapsula_Resource?SWJIYLWA=5074a744e2e3d891814e9a2dace20bd4,719d34d31c8e3a6e6fffd425f7e032f3">
</script>
<body>
</body></html>
--952ed22a92fb817145143eb568f4a4c84ce5a37b--

Exception: Bad Request
SDK HTTP Error at https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/fax
Response text: {
  "message" : "Bad Request",
  "errors" : [ ]
}
Previous: Response has unsuccessful status
#0 /home/drs/public_html/admin/ring-central/vendor/ringcentral/ringcentral-php/src/Platform/Platform.php(329): RingCentral\SDK\Http\Client->send(Object(GuzzleHttp\Psr7\Request))
#1 /home/drs/public_html/admin/ring-central/vendor/ringcentral/ringcentral-php/demo/fax.php(34): RingCentral\SDK\Platform\Platform->sendRequest(Object(GuzzleHttp\Psr7\Request)) 

#2 {main}

7 Answers
answered on Apr 16, 2019 at 12:15pm  
Hello Phong,

Thanks for following up!

Okay, I guess I'll have to convert to PDF first; I was hoping to avoid that.

Maybe a last question (maybe)... I noticed that when I was testing, that if I submitted more than FOUR tests per minute, they were blocked for "too many requests".  Once in production, I'm guessing the client will do 20 or 30 hits within a 5 minute window three or four times per day.  Since the system automatically queue's faxes, why is there a hit limit? And, is there any way to have that lifted?




 0
answered on Apr 16, 2019 at 11:35am  
Hi Nathan,

I just tested and got the same issue. I checked the issue with an engineer and it turns out that we don't render html page as a fax attachment with any other element but texts. So no controls such as checkboxes, radio buttons, table with borders etc. and no images.

So unfortunately, it seems you have to convert to pdf or kind a "screenshot" image then send.

+ Phong

 0
answered on Apr 16, 2019 at 6:14am  
Hello Tyler,

Thank you for responding.

The ico_case_crm.png file was left over from the "out of the box" demo which didn't work.  I wrote a new page to test and it does work - and that page faxes an HTML document.

However, I'm still having trouble with images.  I have changed them to base64 data uri and they still do not appear on the fax.  Here's an example of the embedding syntax - any idea why it will not show up on the fax?

    <img src="data: image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2ODAgMiI+PGRlZnM+PHN0eWxlPi5he2ZpbGw6bm9uZTtzdHJva2U6IzIzMWYyMDtzdHJva2UtbWl0ZXJsaW1pdDoxMDtzdHJva2Utd2lkdGg6MnB4O308L3N0eWxlPjwvZGVmcz48dGl0bGU+cG1wLWxpbmU8L3RpdGxlPjxsaW5lIGNsYXNzPSJhIiB5MT0iMSIgeDI9IjY4MCIgeTI9IjEiLz48L3N2Zz4=" width="680" height="5" style="width: 680px; height: 5px;" />


 0
answered on Apr 15, 2019 at 5:15pm  
You original web post specifies 

Content-Disposition: form-data; name="ico_case_crm.png"; filename="ico_case_crm.png" . Content-Type: image/png

However its content is <html> ...

You were sending HTML while you told the server that it's an image, it woundn't work.

 0
answered on Apr 15, 2019 at 11:00am  
Also, it's returning this URL: https://platform.devtest.ringcentral.com/restapi/v1.0/account/258637004/extension/258637004/message-...

Where the Message changes each time; not sure where the account and extension variables are coming from, they are not part of the Sandbox credentials.

 0
answered on Apr 15, 2019 at 10:56am  
Thanks Phong, 

It did return an error which appears to be that it can't find the GuzzleHTTP dependency, but it did install in the /vendor/ directory.

Can you gleen any info from this response:

Expected HTTP Error: Resource not found  GuzzleHttp\Psr7\Request Object  (      [method:GuzzleHttp\Psr7\Request:private] => GET      [requestTarget:GuzzleHttp\Psr7\Request:private] =>       [uri:GuzzleHttp\Psr7\Request:private] => GuzzleHttp\Psr7\Uri Object          (              [scheme:GuzzleHttp\Psr7\Uri:private] => https              [userInfo:GuzzleHttp\Psr7\Uri:private] =>               [host:GuzzleHttp\Psr7\Uri:private] => platform.devtest.ringcentral.com              [port:GuzzleHttp\Psr7\Uri:private] =>               [path:GuzzleHttp\Psr7\Uri:private] => /restapi/v1.0/account/~/whatever              [query:GuzzleHttp\Psr7\Uri:private] =>               [fragment:GuzzleHttp\Psr7\Uri:private] =>           )        [headers:GuzzleHttp\Psr7\Request:private] => Array          (              [Host] => Array                  (                      [0] => platform.devtest.ringcentral.com                  )                [content-type] => Array                  (                      [0] => application/json                  )                [accept] => Array                  (                      [0] => application/json                  )                [Authorization] => Array                  (                      [0] => bearer U0pDMTJQMDFQQVMwMHxBQUFZVjVYenJFenhWellMemhJWktZTmFVTGtHRjBZNFF3cVBHa09Ca3plTW1ORG9CdDIyZXVpWHFaOXNzNUVqZ0lKNF9QWWRPMEVYNEhPV3FzbEwwTUtuLWlvamdZamh1cXc4RWFEc3FFZ0lVTHZ1aEdlX0tXajhRYU5GN21lVWYyM0VDaWpVT0MwenVOQjU4S3ZoS0tfUDhFbVMzVDMxaWdVQ042eTh2bzRTakJzUVlITzRabWNfaU5zZlZVMFpyU0o0c1hSc1ozdUlNUEhjMlk4Y1lnSVd8YUdjSmJ3fFVERENCS2s1QVA1dWhXZ1QzVmdRT3d8QUE                  )                [User-Agent] => Array                  (                      [0] => Unnamed/0.0.0 Linux/2.6.32-042stab133.2 PHP/7.0.33 RCPHPSDK/2.1.2                  )                [RC-User-Agent] => Array                  (                      [0] => Unnamed/0.0.0 Linux/2.6.32-042stab133.2 PHP/7.0.33 RCPHPSDK/2.1.2                  )            )        [headerNames:GuzzleHttp\Psr7\Request:private] => Array          (              [content-type] => content-type              [accept] => accept              [authorization] => Authorization              [user-agent] => User-Agent              [rc-user-agent] => RC-User-Agent              [host] => Host          )        [protocol:GuzzleHttp\Psr7\Request:private] => 1.1      [stream:GuzzleHttp\Psr7\Request:private] => GuzzleHttp\Psr7\Stream Object          (              [stream:GuzzleHttp\Psr7\Stream:private] => Resource id #78              [size:GuzzleHttp\Psr7\Stream:private] => 0              [seekable:GuzzleHttp\Psr7\Stream:private] => 1              [readable:GuzzleHttp\Psr7\Stream:private] => 1              [writable:GuzzleHttp\Psr7\Stream:private] => 1              [uri:GuzzleHttp\Psr7\Stream:private] => php://temp              [customMetadata:GuzzleHttp\Psr7\Stream:private] => Array                  (                  )            )    )  GuzzleHttp\Psr7\Response Object  (      [reasonPhrase:GuzzleHttp\Psr7\Response:private] => Not Found      [statusCode:GuzzleHttp\Psr7\Response:private] => 404      [headers:GuzzleHttp\Psr7\Response:private] => Array          (              [Server] => Array                  (                      [0] => nginx                  )                [Date] => Array                  (                      [0] => Mon, 15 Apr 2019 17:53:20 GMT                  )                [Content-Type] => Array                  (                      [0] => application/json                  )                [Content-Length] => Array                  (                      [0] => 83                  )                [Connection] => Array                  (                      [0] => keep-alive                  )                [RoutingKey] => Array                  (                      [0] => SJC12P01                  )                [RCRequestId] => Array                  (                      [0] => 5b57ee94-5fa7-11e9-bb0c-005056bba23b                  )            )        [headerNames:GuzzleHttp\Psr7\Response:private] => Array          (              [server] => Server              [date] => Date              [content-type] => Content-Type              [content-length] => Content-Length              [connection] => Connection              [routingkey] => RoutingKey              [rcrequestid] => RCRequestId          )        [protocol:GuzzleHttp\Psr7\Response:private] => 1.1      [stream:GuzzleHttp\Psr7\Response:private] => GuzzleHttp\Psr7\Stream Object          (              [stream:GuzzleHttp\Psr7\Stream:private] => Resource id #80              [size:GuzzleHttp\Psr7\Stream:private] =>               [seekable:GuzzleHttp\Psr7\Stream:private] => 1              [readable:GuzzleHttp\Psr7\Stream:private] => 1              [writable:GuzzleHttp\Psr7\Stream:private] => 1              [uri:GuzzleHttp\Psr7\Stream:private] => php://temp              [customMetadata:GuzzleHttp\Psr7\Stream:private] => Array                  (                  )            )   
)

 0
answered on Apr 15, 2019 at 8:41am  
Hi Nathan,

The demo code does not implement exception handling. Please put the code in "try catch" as shown below to detect the error message.
try {        $rcsdk->platform()->get('/account/~/whatever');    } catch (\RingCentral\SDK\Http\ApiException $e) {        // Getting error messages using PHP native interface      print 'Expected HTTP Error: ' . $e->getMessage() . PHP_EOL;        // In order to get Request and Response used to perform transaction:      $apiResponse = $e->apiResponse();      print_r($apiResponse->request());      print_r($apiResponse->response());        // Another way to get message, but keep in mind, that there could be no response if request has failed completely      print '  Message: ' . $e->apiResponse->response()->error() . PHP_EOL;   
}

 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

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us