question

nuMedia Receptionist avatar image
nuMedia Receptionist asked nuMedia Receptionist commented

Parse Phone Number JSON error

Calling the following code:

var rc = new RestClient("CPWD", "SECRET");

rc.Authorize("PWD", "EXT", "PASSWORD").Wait(60000);

var request = new

{

originalStrings = new[] { phoneNumber }

};

var res = rc.Restapi().NumberParser().Parse().Post(request);

res.Wait(60000);


This code works fine (with real application and user credentials) up until I get to the res.Wait(60000) call.

When I get here I get the following error:

Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'RingCentral.ParsePhoneNumber_CountryInfo[]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.

To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.

Path 'homeCountry.uri', line 4, position 11. Date: 6/25/2019 7:48:16 PM Trace: at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)

at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)

I would like to continue to use the SDK but if there is no way around this error then I can just do a raw REST call.

I am trying to upgrade a legacy application so I am using an older version of the RingCentral.Client SDK version 1.03.


Thanks!

sdk
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.

After more investigation it appears this happens in the most recent version of the RingCentral.Client SDK (version 3.0.0)

0 Likes 0 ·

Happens in the latest version of RingCentral.Net too..

0 Likes 0 ·

1 Answer

Phong Vu avatar image
Phong Vu answered nuMedia Receptionist commented

Hi, I can confirm that it is a bug in the SDK and we are going to fix it as soon as we can.

Meanwhile, here is a workaround solution for this problem:

ParsePhoneNumberRequest request = new ParsePhoneNumberRequest();
request.originalStrings = new string[] { "+11234567890" };
var res = await rc.Post<string>("/restapi/v1.0/number-parser/parse", request);
Console.WriteLine(res); 
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.

Thank you for your prompt reply!


I will give this a shot.


Thanks!

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