question

Marc Church avatar image
Marc Church asked ·

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

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.

c#presencestatus
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

· Write an Answer
Phong Vu avatar image
Phong Vu answered ·

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.

1 comment Share
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Thanks for getting back to me.

That is not a real extension id, just one I made up. The real extension ID I am using is the admin one used to log in. It is the id I am using and not the extension number. I have tried with and without the id, and also with and without the extension number. I left it in so that you can see exactly what I intend doing. Ultimately the admin user logged in will be setting users statuses to offline if they have left themselves in an online state, so the extension id will change.

0 Likes 0 · ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.