Giter Site home page Giter Site logo

ringcentral-csharp-client's Introduction

ringcentral-csharp-client

Build status Coverage Status NuGet Version Chat Twitter


RingCentral.Net

RingCentral.Net is the successor of this project. All users are recommended to use RingCentral.Net instead.

Reference


RingCentral Developers is a cloud communications platform which can be accessed via more than 70 APIs. The platform's main capabilities include technologies that enable: Voice, SMS/MMS, Fax, Glip Team Messaging, Data and Configurations.

API Reference and APIs Explorer.

RingCentral C# client.

Notice: any issues or questions, please do let me know by creating an issue.

Feel free to ⭐ and 🍴 this repository.

Video tutorial

Setup project, authorization and sending fax

Deprecated: Work with .NET 4.5 & WebForm You should not use legacy .NET versions. But if you have to, please watch the video.

Installation

Install-Package RingCentral.Client

API Reference

RingCentral API Reference is where you can find all the endpoints, requests, parameters and all kinds of necessary details.

Please note: as a guest reader, you can only read the basic version of API Reference. Please do login if you want to get information about Advanced API endpoints.

Initialization

using RingCentral;

rc = new RestClient("clientId", "clientSecret");

By default the clients talk to sandbox server. If you want production server:

rc = new RestClient("clientId", "clientSecret", true);

Or you can specify the server url explicitly:

rc = new RestClient("clientId", "clientSecret", "https://platform.devtest.ringcentral.com");

Authorization

await rc.Authorize("username", "extension", "password");

If you use direct number as username, leave extension empty.

Auto refresh

By default, there is a background timer calling rc.Refresh() periodically, so the authorization never expires.

But if you would like to call Refresh manually:

rc.AutoRefreshToken = false;

Token Revoke

When you no longer need a token, don't forget to revoke it: rc.Revoke().

Map URI to code

This client library is built around URIs. Please read this part carefully and make sure you get it before continuing.

Let's go to the RingCentral API Reference to find an example.

We can see that the URI pattern is:

/restapi/v1.0/account/{accountId}/extension/{extensionId}/call-log/{callRecordId}

An real example of the URI could be:

/restapi/v1.0/account/~/extension/130829004/call-log/ASsQ3xLOZfrLBwM

Let's map the URI above to code:

rc.Restapi("v1.0").Account("~").Extension("130829004").CallLog("ASsQ3xLOZfrLBwM");

It's just a one-to-one mapping:

mapping

Default ID

The default ID for Restapi is v1.0, the default ID for Account and Extension is ~.

We can omit arguments to use default value:

rc.Restapi().Account().Extension("130829004").CallLog("ASsQ3xLOZfrLBwM");

You can also break it into multiple lines if you don't like long-chained method calls:

var account = rc.Restapi().Account();
var extension = account.Extension("130829004");
var callLog = extension.CallLog("ASsQ3xLOZfrLBwM");

Anonymous types vs Pre-defined types

For example, the following line is for sending fax:

var response = await extension.Fax().Post(requestBody, attachments);

To create the requestBody object, you can define it as following:

var requestBody = new FaxPath.PostParameters
{
    to = new CallerInfo[] { new CallerInfo { phoneNumber = "123456789" } }
}

Or, you can define it using anonymous types:

var requestBody = new
{
    to = new object[] { new { phoneNumber = "123456789" } }
}

Both are OK. The anonymous types approach is shorter while you can take advantages of IDE intellisense with pre-defined types approach. You can choose based on your preferences.

Talk to API Server

var extension = rc.Restapi().Account().Extension();

GET

List all of the inbound call Logs
var callLogs = await extension.CallLog().List(new { direction = "Inbound" });

Or if you prefer the query parameters as a typed model:

var callLogs = await extension.CallLog().List(new CallLog.ListParameters { direction = "Inbound" });

All the HTTP calls are by default async, so you should use the await keyword of C#.

Get a call log by ID
var callLog = await extension.CallLog("ASsQ3xLOZfrLBwM").Get();

You can inspect the attributes of the returned callLog object because it is a model instead of a string:

Console.WriteLine(callLog.id);
Console.WriteLine(callLog.direction);
Console.WriteLine(callLog.startTime);

POST

Send an SMS
var requestBody = new {
    text = "hello world",
    from = new { phoneNumber = phoneNumber },
    to = new object[] { new { phoneNumber = phoneNumber } }
};
var response = await extension.Sms().Post(requestBody);

PUT

Update message status
var requestBody = new { readStatus = "Read" };
var response = await extension.MessageStore(messageId).Put(requestBody);

DELETE

Delete message by ID
var response = await extension.MessageStore(messageId).Delete();

What if I want plain HTTP without those fancy models?

var endpoint = rc.Restapi().Dictionary().Timezone("6").Endpoint(); // "/restapi/v1.0/dictionary/timezone/6"
var response = await rc.Get(endpoint); // make http request
var statusCode = response.StatusCode; // check status code
var str = await response.Content.ReadAsStringAsync(); // get response string

Subscription

Sample code

The subscription will renew itself automatically before it expires. In rare cases you might need to renew it manually:

await subscription.Renew();

Send Fax

Sample code

Send MMS

MMS and SMS share the same API endpoint. You can deem MMS as SMS with attachments

Sample code

Binary data

Create/Update profile image

Get message content

Download call recording

Sample code

Exception handling

try
{
    await ...
}
catch (FlurlHttpException fhe)
{
    string errorMessage = fhe.GetResponseString();
    Console.WriteLine(errorMessage);
    if (fhe.Call.Response.StatusCode == System.Net.HttpStatusCode.NotFound)
    {
        Console.WriteLine("The resource doesn't exist");
    }
}

Events

  • RestClient class has EventHandler TokenRefreshed, so that every time token refreshed you can get a notification
  • RestClient class has EventHandler AfterHttpCall, so that after every HTTP call you can a notification

Sample code

The unit test project contains lots of useful code snippets. Such as this test class.

License

MIT

Common issues

You must add a reference to assembly netstandard

Ref: dotnet/standard#542

ringcentral-csharp-client's People

Contributors

grokify avatar pacovu avatar rbnswartz avatar tylerlong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ringcentral-csharp-client's Issues

REST API which should support multi target framework(.net 472 and .net core)

I need to create a REST API which should support multi target frameworks(.Net Framework 4.7.2 and .Net Core 2.1) as it has dependencies with other multi targeted libraries and to serve different clients. I created a self hosted API which targets both 472 and .net core frameworks and i created the Controller using the compiler directives as below, so that when it runs on .net full framework this would act as Web API and when it runs on .Net Core this would act as Mvc API:

#if NETCOREAPP2_1
[ApiController]
public class MyController : ControllerBase
#else
public class MyController : ApiController
#endif
{
}

and the return type of API methods also be varied to support different frameworks and it is like,
#if !NETCOREAPP2_1
public IHttpActionResult Score()
#else
public IActionResult Score()
#endif
{
return Ok();
}

This way of building API methods dose not seem good with more compiler directives. May be other option would be using the HttpResponseMessage which is common and available to support for both frameworks. Is there a better way to build an API which could support multi target frameworks?

"Object reference not set to instance of an object"

Hi there,

It appears that my code caught an exception where an "Object reference not set to instance of an object" and the code broke. It appears that InnerException is null for this exception. What could cause this exception, and what is the best way to ensure that the code doesn't break (and it resumes normal activity after resolving the exception) when handling the exception? I haven't stopped the build so if you need any more information, please feel free to reach out to me.

Thank you very much for all your prompt help on these issues.
error

subscription presence stopped working after couple of hours sometimes after couple of days, I still can make a call but no presence

Hello,
I am working on the sdk for few months and I have the following issue:
subscription presence stopped working after couple of hours, sometimes after couple of days, I still can make a call but no presence.

I am using version 1.0.0 from github, also when I use latest ring central sdk from nuget nothing works.
I tried plenty of things and I found when I logged off and log back in after second attempts presence will stop also sometimes Subscription_ConnectEvent raise with very long delay and presence not working as well, is there any issue with pubnub.

when I close the program and run it again it works but it will stop after awhile.

Regards,
Hadi

QUESTION: Subscription: Message Store

I am wanting to subscribe to a particular agent's message store to get voicemails. I have been testing and I seem to only get text messages and no voicemails.

Any Ideas will be greatly appreciated

Code for Subscription
subscription.EventFilters.Add("/restapi/v1.0/account/~/extension/~/message-store");

Details I get from notification

  "uuid": "7057288538622822171",
  "event": "/restapi/v1.0/account/502681018/extension/message-store",
  "timestamp": "2018-07-31T14:19:53.111Z",
  "subscriptionId": "ea8c8b7f-5562-4326-bb8d-a69cd6e4ea77",
  "ownerId": ",
  "body": {
    "accountId": 502681018,
    "extensionId",
    "lastUpdated": "2018-07-31T14:19:47.052Z",
    "changes": [
      {
        "type": "SMS",
        "newCount": 1,
        "updatedCount": 0
      }
    ]
  }
}RingCentralAPI RC_Subscription -- eventString:: /restapi/v1.0/account/502681018/extension/message-store

From RingCentral Get Subscription

  "uri": "https://platform.ringcentral.com/restapi/v1.0/subscription",
  "records": [
    {
      "uri": "https://platform.ringcentral.com/restapi/v1.0/subscription/ea8c8b7f-5562-4326-bb8d-a69cd6e4ea7",
      "id": "ea8c8b7f-5562-4326-bb8d-a69cd6e4ea77",
      "creationTime": "2018-07-31T14:19:05.956Z",
      "status": "Active",
      "eventFilters": [
        "/restapi/v1.0/account/502681018/presence?detailedTelephonyState=true",
        "/restapi/v1.0/account/502681018/extension/message-store"
      ],
      "expirationTime": T14:45:09.739Z",
      "expiresIn": 899,
      "deliveryMode": {
        "transportType": "PubNub",
        "encryption": true,
        "address": "453552330936086_e29e402e",
        "subscriberKey": "sub-c",
        "encryptionAlgorithm": "AES",
        "encryptionKey": "xx"
      }
    }
  ]
}```

Ring Central SDK or Client

I want to create MVC web app to send and receive3 FAX so there are two option you have provided one is SDK and one ios Client. so which one i need to use? I wanrt to send fax from my mvc web applicationm so can you please guide which one i need to use

SMS is being sent 2 times using c# sdk

Hello team,

, i am sending only one but receiving 2 sms messages after an interval of around 5-7 minutes containing the same text. i have verified my code and it executes only time and after that i quit my application. I am using c# SDK.
this was sending only one sms some days back but i am not sure why it is sending multiple sms now. please check
////ring central code starts
var ringCentral = new RingCentral.XDK.ApiClient(appkey, appsecret,defaultendpoint);

                //Login
                ringCentral.Login(userphonenumber, password);

                //Sending SMS
                ringCentral.SMS.Send(fromnumber, phonenumber, msgcontent);

                szResponseString = ringCentral.res;

                var obj = JObject.Parse(szResponseString);
                string statusresp = (string)obj.SelectToken(ConfigurationManager.AppSettings["messagestatuskey"]);
                string messageid = (string)obj.SelectToken(ConfigurationManager.AppSettings["messageidkey"]);

Please find the dev community link below.

https://devcommunity.ringcentral.com/ringcentraldev/topics/sms-is-sending-2-times-through-api

Issue with Nuget Packages in RingCentral.Client for C#

I am using Microsoft Visual Studio Community 2015 Update 3 with Nuget version 3.4.4.1321

When using: Install-Package RingCentral.Client to install ringcentral-charp-client from Nuget Package Manager Console some of the dependency assemblies are not properly installed.

To demonstrate the issue, I included the file with code I am using. In the code, when trying to subscribe to real time notifications (presence) this message is returned in the console:

Could not load file or assembly 'PubNub-Messaging, Version=1.0.6201.20023, Culture=neutral, PublicKeyToken=dc66f52ce6619f44' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

This line triggers the above exception message and no notifications are received:

bool isRegistered = await subscription.Register();

To recreate the issue please try this:

  1. Create New C# Windows Forms project and rename the starting form Form1 to frmMain
  2. Add a button to form frmMain and name it "btnStartNotifications" and add a text box and name it "txtNotifications"
  3. Use Package Manager Console for Nuget and type "Install-Package RingCentral.Client" to install RingCentral CSharp SDK
  4. Copy the code from included sample.txt file to your frmMain .cs file
  5. Provide missing information (with actual values) to code somewhere:
    string ringCentralAppKey = ""; // RingCentral application key
    string ringCentralAppSecret = ""; // RingCentral application secret
    string ringCentralUserName = ""; // RingCentral user id (phone number)
    string ringCentralPassword = ""; // RingCentral password
  6. Run the application, press button btnStartNotifications, and observe txtNotifications for notification messages

Code:
sample.txt

Screenshot of the Error Message:
exception_ringcentral

Authorization issue in RestClient

Hi,
I have installed RingCentral.Client package to call ring out but when come to Authorization flow it gives an error at rc.Authorize(username,"",password);
Below I attached an image, please guide me to get success on it.
capturesnipet

Most Efficient Way to Download Call Recording Immediately After Call Completes

Good evening,

I saw the sample code on the readme of how to download Call Recordings, and I was wondering how to set up "watchers" on specific extensions and triggering the call download as soon as the call completes.

Thank you as always!!!!

This is the code I am referencing:

`var account = rc.Restapi().Account();

// List call Logs
var queryParams = new CallLogPath.ListParameters
{
type = "Voice",
view = "Detailed",
dateFrom = DateTime.UtcNow.AddDays(-100).ToString("o"),
withRecording = true,
perPage = 10,
};
var callLogs = await account.CallLog().List(queryParams);

// download a call recording
var callLog = callLogs.records[0];
var content = await account.Recording(callLog.recording.id).Content().Get();
File.WriteAllBytes("test.wav", content.data);`

issue in installing through nuget

hi,
i am trying to install ringcentral-csharp-client using nuget package manager. but it throw an error
error description below :

Install-Package : 'Flurl.Http' already has a dependency defined for 'Newtonsoft.Json'.
At line:1 char:16

  • Install-Package <<<< RingCentral.Client

Please advice,
Any help would be appreciated!!

Error on subscription registration

Hi,

I am getting error on authorization registration as

Method not found: 'System.Threading.Tasks.Task`1<System.Net.Http.HttpResponseMessage> Flurl.Http.GeneratedExtensions.PostUrlEncodedAsync(Flurl.Http.IFlurlRequest, System.Object, System.Threading.CancellationToken, System.Net.Http.HttpCompletionOption).

Any clue to resolve this?

Create subscription after token refreshed

Hi,

I have set RC object to auto refresh the token, and subscribed to the detailedtelephony event to get incoming call notifcation. I have also subscribed to autorefresh event of RC object to get the refreshed token and assigned it to global RC object.This works fine. I would like to know if the token gets refreshed after every hour or so, do we need to subscribe to the detailedtelephony event again i.e. everytime token get refreshed?

Project ran fine for 290 minutes, then an exception was thrown (see included)

Hi Tyler,

I had this project running for essentially 12 hours last night, with a few starts and stops. Around 290 minutes in, the exception below occurred. I'm still learning how to understand exception messages and I don't really know what to look for in order to find the cause based on this. Do you have any idea what could have caused this?

Thanks!!

System.AggregateException was unhandled by user code
HResult=-2146233088
Message=One or more errors occurred.
Source=mscorlib
StackTrace:
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task1.get_Result()
at FaxVMAPI.Program.Ext1(RestClient rc) in C:\Users\Administrator\Desktop\API\FaxVMAPI\FaxVMAPI\Program.cs:line 53
at FaxVMAPI.Program.OnTimedEvent(Object source, ElapsedEventArgs e, RestClient rc) in C:\Users\Administrator\Desktop\API\FaxVMAPI\FaxVMAPI\Program.cs:line 158
at FaxVMAPI.Program.<>c__DisplayClass0_0.

b__0(Object sender, ElapsedEventArgs e) in C:\Users\Administrator\Desktop\API\FaxVMAPI\FaxVMAPI\Program.cs:line 24
at System.Timers.Timer.MyTimerCallback(Object state)
InnerException:
HResult=-2146233088
Message=Request to https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/message-store/2644719004/content/2644719004 failed with status code 401 (Unauthorized).
Source=Flurl.Http
StackTrace:
at Flurl.Http.Configuration.FlurlMessageHandler.d__1.MoveNext() in C:\projects\flurl\src\Flurl.Http.Shared\Configuration\FlurlMessageHandler.cs:line 59
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Flurl.Http.FlurlClient.d__28.MoveNext() in C:\projects\flurl\src\Flurl.Http.Shared\FlurlClient.cs:line 201
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at RingCentral.RestClient.d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at RingCentral.RestClient.d__5`1.MoveNext()
InnerException:

RingOut won't work

Below is my code.

If I try RingOut, I got a error like Request to https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/ringout failed with status code 400 (Bad Request).

Whats wrong with my code. Kindly reply ASAP

private RestClient rc;
    string from_num_Call = "+18007924060";
    string leadnum = "+1416-721-5424";

    public void Page_Load(object sender, EventArgs e)
    {
        RegisterAsyncTask(new PageAsyncTask(LoadSomeData));
    }

    public async Task LoadSomeData()
    {
        try
        {
            rc = new RestClient("MY_APP_KEY", "MY_APP_SECRET", "https://platform.devtest.ringcentral.com");
            await rc.Authorize("MY_PHONENUMBER", "MY_EXTENSION", "MY_PASSWORD");

            var requestBody = new
            {
                from = new { phoneNumber = "+18007924060" },
                to = new object[] { new { phoneNumber = "+1416-721-5424" } }
            };

            var temp = await rc.Restapi().Account().Extension().Ringout().Post(requestBody);
        }
        catch (Exception ex)
        {
            Alert.ShowAlert(this, ex.Message);
        }
    }

Incoming notification

Hi,
I am not able to get incoming call notification at real time.
Here is my code snippet

`var subscription = rc.Restapi().Subscription().New();

            subscription.EventFilters.Add("/restapi/v1.0/account/~/extension/~/message-store");

            subscription.EventFilters.Add("/restapi/v1.0/account/~/extension/~/presence?detailedTelephonyState=true");

            subscription.EventFilters.Add("/restapi/v1.0/account/~/extension/~/missed-calls");

            subscription.NotificationEvent += (sender, args) =>
            {
                var message = args.message;
                dynamic jObject = JObject.Parse(message);
                var eventString = (string)jObject.@event;
                if (new Regex("/account/\\d+/extension/\\d+/message-store").Match(eventString).Success)
                {
                    var bodyString = JsonConvert.SerializeObject(jObject.body);
                    // If you want to play with raw json string, you can ignore the content below
                    var messageEvent = JsonConvert.DeserializeObject<MessageEvent>(bodyString); // deserialize body to MessageEvent object.
                    Console.WriteLine(messageEvent.changes[0].type);
                }
            };

            subscription.PresenceEvent +=subscription_PresenceEvent;

            //subscription.NotificationEvent += subscription_NotificationEvent;

            subscription.StatusEvent += subscription_StatusEvent;

            await subscription.Register();`

Please let me know if i am missing anything

API request throttling

I am working on building a system that pulls the call logs using the csharp client, and we have an issue here where existing code for this same situation hits the limit of API calls available, and then breaks.

I have been trying to find a clever method of handling the API calls so I can make calls, but it will automatically restrict the number of calls actually performed to be within the limits RingCentral requires (like 10 per minute for Call Logs).

I was wondering if there is any plans on building that into the client code to limit the number of actual API calls automatically.

I have been looking at Reactive Extensions personally, but I am very new to C# so I have a lot of studying to do.

In theory, I would love to be able to.... maybe asynchronously call the API and have it automatically throttle the requests to RingCentral to the request limits we have available, and only make the request/return the result when the throttle allows for it.

Do you have any suggestions for how to accomplish this?

Web Based Project

I am having issue getting this to work on an MVC project. I used it on a winforms app with no difficulty. From what I can gather web based projects require oAuth 2.0 for authorization on the API. Does this client not instigate that? If not how can I go about making it work with oAuth 2.0?

Problem while opening this project

Hello,

I have download this for trail and after downloading successfully, i have tried to open RingCentral.sln but project didnt open properly. You can check in below image or attached image.

12345678

I want to add functionality to send and receive faxes in my ASP.Net MVC application. So do you have any sample project where i can test it.

Can you please guide....

How do I make an API call just to validate account info?

I tried looking through the RingCentral.Test folder but I can't figure out how to write the code that simply makes a request to authenticate the API? Is there documentation on this somewhere that I can follow for the C# client, or perhaps some sample code? How would I pull the Test into my environment and change the credentials to the one for my app?

Thanks!!

HOWTO: How do you Subscription presence entire company

Can I add in a subscription that will listen to the whole companies agents and get back their presence detail

I currently have
subscription.EventFilters.Add("/restapi/v1.0/account//extension//presence?detailedTelephonyState=true");

Access Token expires

Hi,

I have used the RingCentral Client v. 2.3.4.
I have implemented the oAuth authorization to get the access token which is then stored in the DB . We also have set auto refresh token property to true We handled the refresh token event and updated the access token in the database. We use this token from DB to create detailedtelephony event till here every things works fine but after some time might be after couple of hours token get expired. Is there any way so that we can keep this token valid without user intervation.

Authorize method prematurely ending unit test

I am new to RC and trying to use the C# SDK. Call to await rc.Authorize(RingCentralConfig.Instance.username, RingCentralConfig.Instance.extension, RingCentralConfig.Instance.password); is just ending execution of my unit test. The documentation is fairly weak on API response and exception handling. However, since the debug session just ends I have nothing to work with.

App cleared for Production - Need to find specific extensions

I am trying to setup the code such that it monitors the extensions I need to monitor. With this line of code, I only get 100 extensions.
var extensions = rc.Restapi().Account().Extension().List().Result.records;

How do I get the list of all extensions? It also doesn't sort by Extension#. Is there a way to sort these results by Extension#. I need to run this to find their IDs so I can run the code for every specific extension.

Thanks!!

'Flurl.Http' already has a dependency defined for 'Newtonsoft.Json'.

If I am trying to install Ringcentral Client I got Below Error ,

Attempting to resolve dependency 'Flurl (≥ 2.2.1)'.
Attempting to resolve dependency 'Flurl.Http (≥ 1.1.1)'.
'Flurl.Http' already has a dependency defined for 'Newtonsoft.Json'.

I am Using Visual Studio 2010.

Kindly help asap. Thanks in Advance

RingCentral Client issue

I have download the c# Client from the below link
https://github.com/ringcentral/ringcentral-csharp-client

It was giving the below error.

Private RestClient rc; (Unable to resolve the symbol RestClient)

rc.Restapi().Subscription.New (Unable to resolve the symbol Restapi)

I was checking all references added properly and i downloaded the required packages from Nuget Manager.

novice question

I have never worked with your sdk before, and have some very basic questions.

Here's what i am trying to do: I have a c# application that monitors certain business activities. When certain conditions are met, or events occur, I want to initiate an outgoing phone call. and have the user be able to talk to the person on the other end of the call.

The users are using Windows 7 and Windows 10 desktops, and will get a Ring Central Account (they don't have it yet). (By the way, i have been a Ring Central customer for years - but only use the faxing feature).

So I see that i can install the Ring Central library, initiate an rc object, and do stuff like make calls. How the the user actually talk? Will the call automatically open on their Ring Central desktop app? Or is there some other way? Do i need to configure any resources so that they can use a headset on their computer - or is that done for them in the app settings?

Also - it there a minimum level of account that the user will need?

Thanks - I am trying to understand how this will look in action - which was not clear to me yet.

rc.Authorize hangs up

Code below just hangs in rc.Authorize. What am I missing?

namespace CCView
{
public partial class Form1 : Form
{
static RestClient rc = new RestClient(Config.Instance.AppKey, Config.Instance.AppSecret, Config.Instance.ServerUrl);

    public Form1()
    {
        InitializeComponent();
    }

    private void Authorize_RC()
    {
        rc.Authorize(Config.Instance.PBXUsername, Config.Instance.PBXExtension, Config.Instance.PBXPassword);
    }

    private void buttonStart_Click(object sender, EventArgs e)
    {
        Authorize_RC();
    }
}

}

Missing FaxPath.PostParameters

The sample code provided by ringcentral for sending faxes (below) indicates there should be a FaxPath.PostParemeters Type
var attachment1 = new Attachment { fileName = "test.txt", contentType = "text/plain", bytes = Encoding.UTF8.GetBytes("Hello, World!") }; var attachment2 = new Attachment { fileName = "test.pdf", contentType = "application/pdf", bytes = File.ReadAllBytes("test.pdf") }; var attachments = new Attachment[] { attachment1, attachment2 }; var response = await extension.Fax().Post(new FaxPath.PostParameters { to = new CallerInfo[] { new CallerInfo { phoneNumber = "16502305678" } } }, attachments);

"The type name 'PostParameters' does not exist in the type 'FaxPath'"
It appears RingCentral.FaxPath only contains a method for Post.

Call-Forwarding returning null

When I am calling call-forwarding with an extensionId defined it comes back null on all values except URI. When using the API Explorer I get values back. (I have tried this same code with caller-id and it works fine). Here is the code I am using:

RestClient rc = new RestClient(_clientId, _clientSecret);
        await rc.Authorize(_username, _extension, _password);
        var rcClient = rc.Restapi().Account("~");

        List<CallFwdRecord> exts = new List<CallFwdRecord>();
        foreach (DataRow dr in dt.Rows)
        {
            var extn = await rcClient.Extension(dr["id"].ToString()).ForwardingNumber().Get();
}

Note that when I use the API Explorer this is the URI it uses:
https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/237848004/forwarding-number

However when using the charp-client this is the URI it uses:

https://platform.devtest.ringcentral.com/restapi/v1.0/account/237848004/extension/237848004/forwarding-number?page=1&perPage=100

Running in console app

Hello. I've been tasked with building an app that will collect our call logs every day and store them in a database for analysis. I'm having a rather strange problem. I have a windows forms app that I use for testing new stuff and after downloading and building the c# client, I referenced the compiled dll and build some code to get the authorization and grab the call logs. It works as expected.

Happy with that I created a new c# console app, using the same framework, 4.6.2, add the nuget packages and copied the code in. However when it attempts to get the authorization token it causes the program to exit, no exception, just quits. After spending far too long trying to figure out what was different, I decide to create a new Windows forms app since that seemed to work with only what was needed, no problem, it worked fine. I thought perhaps I'd done something wrong in the original console app, so I created another, as with the second forms app, added what was needed for nuget, so they have the same references and indeed the debug output folder has the number of items but it fails in exactly the same way as the first console app I built. I am at a loss, they have the same code, using the same libraries, running on the same computer. I have lots of other command line apps that make https calls but not using flurl.
Do you have any ideas why this would not run in a console app? I did try putting a try/catch block in the RestClient.cs around the call to get the token, "token = await client.PostUrlEncodedAsync(requestBody).ReceiveJson();" but the results are the same, the program just exits with no exceptions. Nothing in the event logs either.

Thanks for any ideas you may have!

Mike

How about a complete example in C#

I find the code fragments in these examples to not be that useful. Could you create a complete example C# application (console) for getting all call logs and displaying the results?

POST Bulk Assign for Call Queues Pointing to GLIP and not Call Queues Object

ISSUE: When trying to POST to update the CallQueue Members I get "Call failed with status code 400 (Bad Request)".

API Using: ringCentral.Restapi().Account("~").CallQueues(groupId.ToString()).BulkAssign().Post(requestBody);

When I started to look into the BulkAssign() I noticed the POST object was explicitly looking at the blow code:
` public class BulkAssignPath : PathSegment
{
protected override string Segment { get; }

    public Task<GlipGroupInfo> Post();
    public Task<GlipGroupInfo> Post(object parameters);
    public Task<GlipGroupInfo> Post(EditGroupRequest parameters);
}`

Can I get some assistance or understanding why I can't POST for CallQueues?

RingCentral API Reference https://developer.ringcentral.com/api-reference#Account-Provisioning-updateCallQueueGroup

Not able to generate access tokens after Authorization

Hi,

I have developed application using the GitHub library and using API version 0.34 and I am now making logging request in Sandbox environment and after clicking on Authorize button I am getting new blank screen and when in debugging mode I checked I am getting null tokens. Please can anybody help me on how to fix this issue?.

Regards

Signed/StrongNamed version?

Have you given any thought to publishing a version signed with a strong named key? I know there is a flurl and flurl.http available via nuget that are signed that could be used with it. Sorry if this has been asked before. I couldn't find anything about it.

Thanks!

Could not load file or assembly 'PubNub-Messaging, Version=1.0.6201.20023

The following was posted on the RingCentral Dev Community:

https://devcommunity.ringcentral.com/ringcentraldev/topics/pubnub


I am integrating ring central c# package to asp.net mvc5 application.Autherization is done and when i try to call subscription it shows an error like

Could not load file or assembly 'PubNub-Messaging, Version=1.0.6201.20023, Culture=neutral, PublicKeyToken=dc66f52ce6619f44' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"PubNub-Messaging, Version=1.0.6201.20023, Culture=neutral, PublicKeyToken=dc66f52ce6619f44"

when i installed ring central client it added pubnub-messaging version 1.0.6151.29001, now i am unable to change the package.

This is my code,

var subscription = rc.Restapi().Subscription().New();

                subscription.EventFilters.Add("/restapi/v1.0/account/~/extension/~/message-store");

                subscription.EventFilters.Add("/restapi/v1.0/account/~/extension/~/presence");

                subscription.ConnectEvent += (sender, args) =>
                {

                    Console.WriteLine("Connected:");

                    Console.WriteLine(args.Message);

                };

                subscription.NotificationEvent += (sender, args) =>
                {

                    Console.WriteLine("Notification:");

                    Console.WriteLine(args.notification);

                };

                subscription.ErrorEvent += (sender, args) =>
                {

                    Console.WriteLine("Error:");

                    Console.WriteLine(args.Message);

                };

                var sub = await subscription.Register();

SMS Post with attachment returns FaxResponse

Passing attachments to the extension.Sms().Post method call returns a FaxResponse. When calling Post without passing attachments the return value is GetMessageInfoResponse. Is this by design or a bug?

var attachment1 = new Attachment { fileName = "attachment.jpg", contentType = "image/jpg", bytes = Convert.FromBase64String(base64Image) };
var attachments = new Attachment[] { attachment1 };
var response = await extension.Sms().Post(new
  {
         to = new CallerInfo[] { new CallerInfo { phoneNumber = telephoneNumber } },
         from = new CallerInfo { phoneNumber = RingCentralConfig.Instance.username },
         text = messageText
  }, attachments);

.Net Core Webhosting not able to find the referenced package assemblies Micorsoft.AspNetCore

We are in the process of making projects of our application in to target multiple frameworks and i need to self host an API from a .Net Core class library which has to be initiated from a .Net Core console application.
I used WebHost.CreateDefaultBuilder() to host the service, however it throws a runtime error as Could not load the referenced package assembly Microsoft.AspNetCore. When the packages are referenced, the assemblies are copied under C:\Users..nuget\packages folder however the system is expecting these assemblies under bin folder of the application. When i am copying all the required assemblies in to bin folder the application runs.

var webHost = WebHost.CreateDefaultBuilder()
.UseStartup()
.Build();
webHost.Start();

System.IO.FileLoadException with "PubNub-Messaging"

Hello,

I'm trying to make a basic program that reads inbound numbers. At the moment I just have the basic initialization, authorization, and subscription included within my code from the README, but I'm getting this error:

"System.IO.FileLoadException: Could not load file or assembly 'PubNub-Messaging, Version=1.0.6201.20023, Culture=neutral, PublicKeyToken=dc66f52ce6619f44' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at RingCentral.SubscriptionService.Alive()
at RingCentral.SubscriptionService.d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at InboundNumber.Program.<>c.<

b__0_0>d.MoveNext() in C:\Users\james.ho\Documents\Visual Studio 2015\Projects\RingCentral\InboundNumber\InboundNumber\Program.cs:line 63
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at InboundNumber.Program.Main(String[] argsIgnore) in C:\Users\james.ho\Documents\Visual Studio 2015\Projects\RingCentral\InboundNumber\InboundNumber\Program.cs:line 14"

I have tried re-installing the Nuget packages and that fixed some previous issues, but I'm not too sure how to resolve this one with PubNub. I have tried using the latest version and the one installed with installing the package for RingCentral but neither seems to work.

Authorize returns Faulted Status

Hi
I am trying get RingCentral notification for incoming call in real time.
I am using VS2013 Express with .net framework 4.5.2

I am not able to get authorize token it always return faulted status
Below is my code snippets

private void button1_Click(object sender, EventArgs e)
       {
        

           //rc = new RestClient(txtClientID.Text, txtClientSecrete.Text, !chkIsSandBox.Checked);
           rc = new RestClient(txtClientID.Text, txtClientSecrete.Text);
           Task<TokenInfo> tokenInfo = Authorize();
           
           RegisterSubscription();
          

       }

       async void RegisterSubscription()
       {
           var subscription = rc.Restapi().Subscription().New();

           //subscription.EventFilters.Add("/restapi/v1.0/account/~/extension/~/message-store");

           subscription.EventFilters.Add("/restapi/v1.0/account/~/extension/~/presence");

           subscription.PresenceEvent += subscription_PresenceEvent;

           await subscription.Register();
       }

       void subscription_PresenceEvent(object sender, SubscriptionEventArgs e)
       {
           rtLog.Text += e.Message;
       }
       private async Task<TokenInfo> Authorize()
       {
           rc.AutoRefreshToken = true;
           return await rc.Authorize(txtUsrName.Text, txtExtension.Text, txtPWD.Text);

       }

Error image
image

Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.