question

Angelo Bevilacqua avatar image
Angelo Bevilacqua asked Carl McFarland commented

C# SDK - Get X-Rate-Limit headers from response

Using the RingCentral.Net SDK - how do retrieve the X-Rate-Limit-* headers from the responses ?

rest api
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Khadhar Koneti avatar image
Khadhar Koneti answered Angelo Bevilacqua edited
1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Angelo Bevilacqua avatar image Angelo Bevilacqua commented ·

Thanks for the link but it does not show how to get the headers using the .Net SDK.

0 Likes 0 ·
Phong Vu avatar image
Phong Vu answered Angelo Bevilacqua commented

Using the RingCentral .Net SDK, you can check API limit header as shown below:

static RestClient rcsdk;

static void Main(string[] args)
{
  rcsdk = new RestClient(RINGCENTRAL_CLIENTID, RINGCENTRAL_CLIENTSECRET, RINGCENTRAL_PRODUCTION);
  rcsdk.Authorize(RINGCENTRAL_USERNAME, RINGCENTRAL_EXTENSION, RINGCENTRAL_PASSWORD).Wait();
  rcsdk.AfterHttpCall += EventHandler;
}
static void EventHandler(object sender, HttpCallEventArgs eventArgs)
{
  var rateLimitRemaining = eventArgs.httpResponseMessage.Headers.First(i => i.Key == "X-Rate-Limit-Remaining").Value.First();
  Console.WriteLine("Remaining: " + rateLimitRemaining);
}
1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Angelo Bevilacqua avatar image Angelo Bevilacqua commented ·

Perfect, thanks for all your help.

0 Likes 0 ·
Ravindra Jumrani avatar image
Ravindra Jumrani answered Phong Vu edited

Hi Phong Vu,

I don't see AfterHttpCall in my ringcentral DLL. (Assembly RingCentral.Net, Version=1.0.0.0)

I am using Nuget Packaage.


Am I missing something...

1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image Phong Vu ♦♦ commented ·

What version of the RingCentral .NET SDK do you use?

0 Likes 0 ·
Brandon Poindexter avatar image
Brandon Poindexter answered Brandon Poindexter edited

This does not work in RingCentral.net SDK version 5.2. The AfterHTTPCall event does not exist.

1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered Carl McFarland commented

RingCentral .NET SDK 5.x has major changes and there are many source breaks. It supports SDK extensions mechanism. And to catch the events, create and install the EventsExtension as shown below:

RestClient rcsdk = new RestClient(RC_CLIENTID, RC_CLIENTSECRET, RC_PRODUCTION);
rcsdk.Authorize(RC_USERNAME, RC_EXTENSION, RC_PASSWORD).Wait();
var eventsExtension = new EventsExtension();
rcsdk.InstallExtension(eventsExtension).Wait();
eventsExtension.RequestSuccess += EventHandler;
...
static void EventHandler(object sender, HttpMessages httpMessages)
{
    var rateLimitRemaining = httpMessages.httpResponseMessage.Headers.First(i => i.Key == "X-Rate-Limit-Remaining").Value.First();
    Console.WriteLine("Remaining: " + rateLimitRemaining);
}
2 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Brandon Poindexter avatar image Brandon Poindexter commented ·

I will try this and report back.

0 Likes 0 ·
Carl McFarland avatar image Carl McFarland commented ·
  1. var eventsExtension = new EventsExtension();

What do I have to do to make it work for EventsExtension as I am getting an error to create a namespace for it. Do I have to install some package from Nuget?

What do you mean by "create and install the EventsExtension as shown below: ". Can you clarify this?

0 Likes 0 ·
Anirban avatar image
Anirban answered Carl McFarland commented
1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Carl McFarland avatar image Carl McFarland commented ·

I will try this and report back. Thank you for quick reply.

0 Likes 0 ·

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys