Question

Update User Queue Agent Presence


I am trying to update the dndStatus for end users if they are not in the Q. So far I have this


$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, "https://platform.ringcentral.com/restapi/v1.0/account/" . $RCaccountId . "/extension/" . $callerID . "/presence");
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $FINALHEADERS);
curl_setopt($curl_handle, CURLOPT_PUT, true);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, '{"dndStatus": "TakeAllCalls"}');

$buffer = curl_exec($curl_handle);



The response I get is

Fatal error: Maximum execution time of 30 seconds exceeded


Any help will be much appreciated.


Thank You

Andy



11 replies

Update I am now getting a 415, Unsupported attachment media type. I changed the Put statement and put it in the header. X-HTTP-Method-Override: PUT

the data that I am passing is 
$REQUEST_BODY = '{"dndStatus": "TakeAllCalls"}';
So I updated my erroring and I don't have EditPresence

The question I have is how do I get this. I looked at creating a new app but only Edit Messages were there.

{ "errorCode" : "InsufficientPermissions", "message" : "In order to call this API endpoint, application needs to have [EditPresence] permission", "errors" : [ { "errorCode" : "CMN-401", "message" : "In order to call this API endpoint, application needs to have [EditPresence] permission", "permissionName" : "EditPresence" } ], "permissionName" : "EditPresence" }


Thank You
Andy

Andy,


You would need to add the 'EditPresence' permission on your application in order to exercise this API endpoint.


Email the developer support team or submit a support ticket with your appKey and the necessary details and we would add the permission on your application at the earliest.

AK,
I have emailed you the appKey. Please let me know if you need anything else.

Thank You
Andy
Still Getting an 415 Unsupported Media Type. Here is the written code


$REQUEST_BODY = '{"dndStatus":"TakeAllCalls"}';

curl_setopt_array($curl, array(
                CURLOPT_URL => " https://platform.ringcentral.com/restapi/v1.0/account/"; . $RCaccountId . "/extension/" . $callerID . "/presence",
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_MAXREDIRS => 10,
                CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYPEER => false,
                CURLOPT_CUSTOMREQUEST => "PUT",
                CURLOPT_POSTFIELDS => '{"dndStatus":"TakeAllCalls"}',
                CURLOPT_HTTPHEADER => [$REQUEST_HEADER_authorization, "Accept: application/json"]
            ));


I do now have EditPresence enabled on this project. 

Thank You
Andy

We have added the permission on your application. Did it work?

Oh thats easy, I guess you are missing the "Content-Type: application/json" header. Could you try with the header please. 
AK,
Thank You for that.

Now missing another permission
{ "errorCode" : "CMN-408", "message" : "[EditPresenceStatus] permission required", "errors" : [ { "errorCode" : "CMN-408", "message" : "[EditPresenceStatus] permission required", "permissionName" : "EditPresenceStatus" } ], "permissionName" : "EditPresenceStatus" }{ "errorCode" : "CMN-408", "message" : "[EditPresenceStatus] permission required", "errors" : [ { "errorCode" : "CMN-408", "message" : "[EditPresenceStatus] permission required", "permissionName" : "EditPresenceStatus" } ], "permissionName" : "EditPresenceStatus" }

Thank You for Everything.
Andy

Andy,

Please keep in mind that you cannot Update the Presence on an Extension if you are not logged in as that extension unless you are a Super Admin.

I am doing this through the API. I am reading this doc to do exactly what we want to do. 

If an end user is not in the Q we want to be able to programmatically edit their status.

Update User Queue Agent Presence

To enable or disable an user extension's queue agent presence, update the extension's presence dndStatus property.

http://ringcentral-api-docs.readthedocs.io/en/latest/call_queue/

Thank You
Andy
Andy, only administrator can update presence status of other users (regular users can only update their own statuses). So you has to be authenticated as an admin user with corresponding permissions to call this API.
On the API how do I log in as an admin. Currently when I get my token I log in as the main account which is a Super Admin already.

Thank You
Andy

Reply