C# Sending SMS thows System.UriFormatException: 'Invalid URI: The format of the URI could not be determined.'

  • 1
  • Question
  • Updated 2 months ago
Trying to send a simple SMS with this code it throws
public void SendText()
        {
           //This throws System.UriFormatException: 'Invalid URI: The format of the URI could not    //be determined.' at this point
            var sdk = new SDK(appkey, appSecret, "SDK.Server.Sandbox", " MyApp", "1.0.0");
            var jsonString = "{ \"text\":  \"TryThis RC!\", \"from\": { \"phoneNumber\": \"+15558881212\" }, \"to\": [{ \"phoneNumber\": \"+18008675309\" }] }";
            var request = new Request("/restapi/v1.0/account/~/extension/~/sms", jsonString);
            var response = sdk.Platform.Post(request);
         
        }

What am I doing wrong?




Photo of Rick Smith

Rick Smith

  • 412 Points 250 badge 2x thumb

Posted 2 months ago

  • 1
Photo of Phong Vu

Phong Vu, Devangelist

  • 3,192 Points 3k badge 2x thumb
Hi Rick,

Not sure what SDK do you use. Please refer to our official SDK for C-Sharp and use it to access RingCentral Platform. Have a look at the sample code for sending SMS

Hope this helps,
+ Phong 
Photo of Rick Smith

Rick Smith

  • 412 Points 250 badge 2x thumb
Hi Phong
Im using v4.0.30319 is that deprecated? The code Im seeing via the above URL is completely different?  Furthermore the code seems to be wrong??

This does not work in vs2017
rc = new RestClient("clientId", "clientSecret");

Any Ideas?


Thanks
Rick

UPDATE
Code on this page https://github.com/ringcentral/ringcentral-csharp-client is completely wrong as far as I can tell. Does your product even work with C# and VS2017?

(Edited)
Photo of John Wang

John Wang, Official Rep

  • 5,664 Points 5k badge 2x thumb
> Code on this page https://github.com/ringcentral/ringcentral-csharp-client is completely wrong as far as I can tell. Does your product even work with C# and VS2017?

This works with C#. Travis CI runs the following C# tests with each commit:

https://github.com/ringcentral/ringcentral-csharp-client/tree/master/RingCentral.Test

You can see the Travis CI builds here:

https://travis-ci.org/ringcentral/ringcentral-csharp-client/builds

While the latest cron build failed and needs to be investigated, you can see that the code works in general for the previous builds.
(Edited)
Photo of Tyler Long

Tyler Long, Official Rep

  • 8,492 Points 5k badge 2x thumb
Hi Rick,

Last month I created a video for how to setup a new project. Please watch this: https://www.youtube.com/watch?v=lECKMrX_Dgw&t=10s