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
How do I change user presence status in RingCentral programatically using c#? Question 1
Tags: sdk
May 31, 2019 at 4:46am   •   2 replies  •  0 likes
Marc Church

I have created as program in C# that is designed to display the users status and availability from Ring Central. This works brilliantly and I can sort the users by availability, name, etc.

I need to add the functionality to change the status of the user to "Offline". When the users shift ends they would be set to receive calls when they have gone home, we need to stop that.

The problem I have is that the RingCentral SDK I am using is saying it needs a parameter which should be of type PresenceInfoResource. here is the path I am using:

rc.Restapi().Account().Extension().Presence().Put();

I have tried various different types but I cannot seem to get, create or cast to a type of PresenceInfoResource.

Does anyone know what it is looking for, how to change the status in c# or where I am going wrong?

I have looked in the RingCentral documentation on line, but can't find anything, only a link to the update presence page which has nothing about PresenceInfoResource: https://developers.ringcentral.com/api-reference/Presence/updateUserPresenceStatus

1 Answer
answered on Jun 3, 2019 at 7:34am  

I have been using the code given below by Phong , but no matter what happens, I always get an error:

Error Message: Cannot access a disposed object.

Object name: 'System.Net.Http.StringContent'.

Here is the code i am using, any help would be greatfully appreciated:

RestClient rc = new RestClient(clientid, clientsecret, false);

await rc.Authorize("username", "extension", "password"); //Sandbox

var parameters = new PresenceInfoResource();

parameters.userStatus = "Available";

parameters.dndStatus = "TakeAllCalls";

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);

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


 0
answered on May 31, 2019 at 8:14am  

Hi Marc,

Here you go:

var parameters = new PresenceInfoResource();
parameters.userStatus = "Busy";
parameters.dndStatus = "TakeAllCalls";
var resp = await rc.Restapi().Account().Extension().Presence().Put(parameters);   
Console.WriteLine("User presence status: " + resp.userStatus);
Console.WriteLine("User DND status: " + resp.dndStatus);

 1



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