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
PresenceInfoResource Missing From .NET SDK?
Tags: rest api, sdk, .net sdk, ringcentral.net sdk
Oct 21, 2021 at 7:37am   •   2 replies  •  0 likes
Nate Breeden

Trying to change user presence, at first I was trying to just use the below snippet from the RC Developer API (tweaking what I wanted to use, and adding all of my API information to it)


https://developers.ringcentral.com/api-reference/Presence/updateUserPresenceStatus

// https://developers.ringcentral.com/my-account.html#/applications
// Find your credentials at the above url, set them as environment variables, or enter them below

// PATH PARAMETERS
string extensionId = "<ENTER VALUE>";
string accountId = "<ENTER VALUE>";

// POST BODY
PresenceInfoResource presenceInfoResource = new PresenceInfoResource {
    userStatus = 'Offline',
    dndStatus = 'TakeAllCalls',
    message = "<ENTER VALUE>",
    allowSeeMyPresence = true,
    ringOnMonitoredCall = true,
    pickUpCallsOnHold = true,
    activeCalls = new[] {
        new ActiveCallInfo {
            id = "<ENTER VALUE>",
            direction = 'Inbound',
            from = "<ENTER VALUE>",
            fromName = "<ENTER VALUE>",
            to = "<ENTER VALUE>",
            toName = "<ENTER VALUE>",
            startTime = "<ENTER VALUE>",
            telephonyStatus = "<ENTER VALUE>",
            sipData = new DetailedCallInfo {
                callId = "<ENTER VALUE>",
                toTag = "<ENTER VALUE>",
                fromTag = "<ENTER VALUE>",
                remoteUri = "<ENTER VALUE>",
                localUri = "<ENTER VALUE>",
                rcSessionId = "<ENTER VALUE>"
            },
            sessionId = "<ENTER VALUE>",
            terminationType = "<ENTER VALUE>"
        },
    }
};

RestClient rc = new RestClient(
    Environment.GetEnvironmentVariable("clientId"),
    Environment.GetEnvironmentVariable("clientSecret"),
    false
);
await rc.Authorize(
    Environment.GetEnvironmentVariable("username"),
    Environment.GetEnvironmentVariable("extension"),
    Environment.GetEnvironmentVariable("password")
);
var r = await rc.Restapi().Account(accountId).Extension(extensionId).Presence().Put(presenceInfoResource);
// PROCESS RESPONSE


Once setting everything up for what I want to use, C# is giving an error that "PresenceInfoResource" does not exist inside RingCentral's SDK. After digging through, I've found that it really doesn't exist in the SDK as far as I can see? Is the documentation for this call out of date?

https://github.com/ringcentral/RingCentral.Net/tree/master/RingCentral.Net/Definitions


Here is what it should be if it's truly out of date:


// https://developers.ringcentral.com/my-account.html#/applications
// Find your credentials at the above url, set them as environment variables, or enter them below

// PATH PARAMETERS
string extensionId = "<ENTER VALUE>";
string accountId = "<ENTER VALUE>";

// POST BODY
PresenceInfoRequest presenceInfoRequest = new PresenceInfoRequest
{
    userStatus = 'Offline',
    dndStatus = 'TakeAllCalls',
    message = "<ENTER VALUE>",
    allowSeeMyPresence = true,
    ringOnMonitoredCall = true,
    pickUpCallsOnHold = true
};

RestClient rc = new RestClient(
    Environment.GetEnvironmentVariable("clientId"),
    Environment.GetEnvironmentVariable("clientSecret"),
    false
);
await rc.Authorize(
    Environment.GetEnvironmentVariable("username"),
    Environment.GetEnvironmentVariable("extension"),
    Environment.GetEnvironmentVariable("password")
);
var r = await rc.Restapi().Account(accountId).Extension(extensionId).Presence().Put(presenceInfoRequest);
// PROCESS RESPONSE
2 Answers
answered on Oct 21, 2021 at 9:38am  

Yes, the sample code generator from the API reference is not up-to-date. Apologies for that. To better use the .NET SDK, I recommend, first always update to use the latest SDK, and use this resource to find out the syntax and sample code to call an API.


 2
on Oct 21, 2021 at 9:45am   •  0 likes

That's really useful, thanks as always Phong

answered on Oct 21, 2021 at 8:49am  

Please check once, if below reference still applies or helps you:

https://community.ringcentral.com/questions/7525/how-do-i-change-user-presence-status-in-ringcentra.html


 1
on Oct 21, 2021 at 9:44am   •  0 likes

Nope, that one uses PresenceInfoResource and should be using PresenceInfoRequest


Just trying to help more than anything as this took me a while to figure out the proper method to use.



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