Solved

PresenceInfoResource Missing From .NET SDK?

  • 21 October 2021
  • 4 replies
  • 434 views

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
icon

Best answer by Phong1426275020 21 October 2021, 18:38

View original

4 replies

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

Userlevel 1

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.

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.

That's really useful, thanks as always Phong

Reply