Skip to main content
Answer

PresenceInfoResource Missing From .NET SDK?

  • October 21, 2021
  • 4 replies
  • 483 views

Forum|alt.badge.img

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

Best answer by PhongVu

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.

4 replies


PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • Answer
  • October 21, 2021

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.


Forum|alt.badge.img
  • Author
  • Inspiring
  • October 21, 2021

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.


Forum|alt.badge.img
  • Author
  • Inspiring
  • October 21, 2021

That's really useful, thanks as always Phong