Skip to main content

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!

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

Reply