Question

How do I change user presence status in RingCentral programatically using c#? Question 2

  • 3 June 2019
  • 1 reply
  • 804 views

Further to my last question,

How do I change user presence status in RingCentral programatically using c#? ,

which was answered by Phong Vu, I have been using the code given by Phong , but no matter what happens, I always get the following error:

Error Message: Cannot access a disposed object.
Object name: 'System.Net.Http.StringContent'.

Here is the code I am using:

RestClient rc = new RestClient(clientid, clientsecret, false);
await rc.Authorize("username", "extension", "password"); //Sandbox
var parameters = new PresenceInfoResource();
parameters.userStatus = "Offline";
parameters.dndStatus = "DoNotAcceptAnyCalls";
parameters.message = "Changed by Program";
parameters.allowSeeMyPresence = true;
parameters.ringOnMonitoredCall = false;
parameters.pickUpCallsOnHold = false;
var resp = await rc.Restapi().Account().Extension(12345678).Presence().Put(parameters);

I have tried with the extension number and also the id.

If I change line the last line to a Get without parameters instead of a Put it retrieves the information as expected:

var resp = await rc.Restapi().Account().Extension(12345678).Presence().Get();

Any help would be greatfully appreciated.


1 reply

Userlevel 1

Hi Marc,

While this may not be the cause to your problem, where did you get the extension id Extension(12345678)? Does the id belong to the extension you logged in? If it is the same extension, then you don't need to specify the id within the Extension(). If it is another extension under the same account, then make sure that you are login with an admin extension which has the right to change status of other extension under the same account.

Meanwhile, I will look into the problem to see what could be the cause and let you know soon.

Reply