question

Caleb Bluesummers avatar image
Caleb Bluesummers asked ·

C#: Resource for parameter [extensionId] is not found

I am trying to pull users presence data in C#

I was able to get the AccountId and the ExtensionId from here:


Here is my code:

using System;
using System.Threading.Tasks;
using RingCentral;

namespace Send_SMS
{
    class Program
    {
        const string RINGCENTRAL_CLIENTID = "<>";
        const string RINGCENTRAL_CLIENTSECRET = "<>";

        const string RINGCENTRAL_USERNAME = "<>";
        const string RINGCENTRAL_PASSWORD = "<>";
        const string RINGCENTRAL_EXTENSION = "<>";

        const string RINGCENTRAL_PRESENCE_USER = "<>";
        const string RINGCENTRAL_PRESENCE_EXT = "101";


        static RestClient restClient;

        static void Main(string[] args)
        {

            restClient = new RestClient(RINGCENTRAL_CLIENTID, RINGCENTRAL_CLIENTSECRET, false);
            restClient.Authorize(RINGCENTRAL_USERNAME, RINGCENTRAL_EXTENSION, RINGCENTRAL_PASSWORD).Wait();
            get_presence().Wait();

        }
 
        static private async Task get_presence()
        {

            // OPTIONAL QUERY PARAMETERS
            ReadUserPresenceStatusParameters readUserPresenceStatusParameters = new ReadUserPresenceStatusParameters
            {
                //detailedTelephonyState = true,
                //sipData = true
            };

            var response = await restClient.Restapi().Account(RINGCENTRAL_PRESENCE_USER).Extension(RINGCENTRAL_PRESENCE_EXT).Presence().Get(readUserPresenceStatusParameters);

            Console.WriteLine("Presence for Test Account: " + response.presenceStatus);
        }

    }
}


Everything in <> is filled out of course, and tested with the SMS_Send tutorial.

My error:

Content: {"errorCode":"CMN-102","message":"Resource for parameter [extensionId] is not found","errors":[{"errorCode":"CMN-102","message":"Resource for parameter [extensionId] is not found","parameterName":"extensionId"}],"parameterName":"extensionId"}


Thanks in advance. I'm really struggling to understand the account/extension side of this API.

c#presenceextension api
1596815216843.png (26.6 KiB)
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
Anirban Sen Chowdhary avatar image
Anirban Sen Chowdhary answered ·

This is because you are not giving correct extension id number. You can get all the id numbers for all your extensions with this API

GET https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~


It will return response with account id number and extension id number. example:

"uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/account/123456789/extension/987654321";,


account id number will be 123456789 and extension id number will be 987654321

2 comments 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.

OK, thank you again Anirban. I was able to pull it from the same screenshot. The extensionId = accountId, as they are identical.

So the 'extensionId' is not the same as the 'extension' listed in the accounts page. This is very confusing for beginners. I went through the tutorials, but this:

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

Does not clarify anything at all. I highly suggest explaining what those should look like in the tutorial, or even use a dummy value so that people can see the difference. I found them after your help by expanding all the options in the API-reference.


Thanks again, I'm sure I'll have more questions...

0 Likes 0 · ·
Phong Vu avatar image Phong Vu ♦♦ Caleb Bluesummers ·

FYI,

1. The account id is not the same as the extension id except for the main extension (first extension e.g. 101).

2. Some developers are confused between extension id and extension number. They are different. This is what you were doing wrong too

Extension(RINGCENTRAL_PRESENCE_EXT)

3. The SDK does not require you to specify the account id and the extension id if you call the API for the extension you logged in. Simply call this to get the presence info of the extension you are logged in. Or see the dev guide

var response = await restClient.Restapi().Account().Extension().Presence().Get(readUserPresenceStatusParameters);


The tutorial is about sending SMS and it does not require you specify the extension id. Because you add the get_presence() method and specified the params incorrectly.

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.