Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetChartDataAsync() fails to deserialize JSON object into IList<MarketChartData> #5

Open
misthema opened this issue Feb 21, 2016 · 1 comment

Comments

@misthema
Copy link

Using this line:
data = Shared.PoloniexClient.Markets.GetChartDataAsync(CurrencyPair.Parse(market), MarketPeriod, epoch, DateTime.UtcNow).Result;

...gives me these errors:

System.AggregateException: One or more errors occurred. ---> Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.IList`1[Jojatekok.PoloniexAPI.MarketTools.MarketChartData]' 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 'error', line 1, position 9.
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
   at Jojatekok.PoloniexAPI.Helper.DeserializeObject[T](JsonSerializer serializer, String value) in D:\C#\libs\PoloniexApi.NET\PoloniexApi.Net-1.2.0-source\PoloniexApi.Net\Helper.cs:line 51
   at Jojatekok.PoloniexAPI.ApiWebClient.GetData[T](String command, Object[] parameters) in D:\C#\libs\PoloniexApi.NET\PoloniexApi.Net-1.2.0-source\PoloniexApi.Net\General\ApiWebClient.cs:line 43
   at Jojatekok.PoloniexAPI.MarketTools.Markets.GetData[T](String command, Object[] parameters) in D:\C#\libs\PoloniexApi.NET\PoloniexApi.Net-1.2.0-source\PoloniexApi.Net\MarketTools\Markets.cs:line 107
   at Jojatekok.PoloniexAPI.MarketTools.Markets.GetChartData(CurrencyPair currencyPair, MarketPeriod period, DateTime startTime, DateTime endTime) in D:\C#\libs\PoloniexApi.NET\PoloniexApi.Net-1.2.0-source\PoloniexApi.Net\MarketTools\Markets.cs:line 59
   at Jojatekok.PoloniexAPI.MarketTools.Markets.<>c__DisplayClass14_0.<GetChartDataAsync>b__0() in D:\C#\libs\PoloniexApi.NET\PoloniexApi.Net-1.2.0-source\PoloniexApi.Net\MarketTools\Markets.cs:line 91
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()

PoloniexApi.NET version: 1.2.0.0
Newtonsoft.Json version: 6.0.0.0
Newtonsoft.MsgPack version: 1.0.0.0

@misthema
Copy link
Author

Okay, it looks like the errors are not handled? I got it working with some debugging. The error came from these JSON contents:
{"error":"Invalid currency pair."}
{"error":"Please specify a valid period."}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant