Closed juanredondo closed 6 years ago
Guessing this is due to the fact that WaterSport is not yet a mapped value in the ActivityType enum in the project https://github.com/gabornemeth/StravaSharp/blob/1db6fd4c9656d3a178b0b5b27dd6fdd1856f3ba9/src/StravaSharp/Activity.cs
Need to add that for the json conversion to work
How old is that workout? I have included activity types stated here: https://strava.github.io/api/v3/activities/#get-details WaterSport is not included, but I have found it in Strava's public code too: https://github.com/strava/go.strava/blob/master/activities.go Guess it's some legacy type, because I cannot select it if manually trying to add new activity on Strava. Although I consider adding it for compatibility.
You could also try to map the ActivityType from JSON to a string property and add your own Enum property that has some logic to filter out unknown types and return ActivityType.Generic instead. That way apps won't fail / break. Problem with that you'll need to keep track on a regular basis to see if new types are added.
The workout is not very old, September of 2017. Maybe if the workout is created by a personal training device this type appears, even when the WaerSport is not selectable on STRAVA itself
Looking at other apps... seems that there was once a change for that type needed and should be rowinig? https://github.com/thomaschampagne/stravistix/issues/437 https://gist.github.com/lawrencejones/ae51070ffbc258d9add2#file-all_activities-rb-L82
@Depechie Thank you for the research 👍 I have added WaterSport as a supported legacy activity type. Marked with obsolete attribute. Added a unit test as well. @juanredondo Please try whether it is working now! If you consume as nuget package, please use 0.5.1 from this myget feed. Going to update official nuget feed as well if fix is confirmed.
I can't see an update using your nuget feed
No success? 0.5.1 is available from the above Nuget feed. I have tested on multiple machines.
Now it's updating ok. I don't know whats happen before, i didn't change anything on my visual studio. I suposed, the machine needs a restarts or something similar.
I check the failing process and the error is now gone.
Thanks for the help
El mar., 12 dic. 2017 a las 14:16, Németh Gábor (notifications@github.com) escribió:
No success? 0.5.1 is available from the above Nuget feed. I have tested on multiple machines.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gabornemeth/StravaSharp/issues/3#issuecomment-351048210, or mute the thread https://github.com/notifications/unsubscribe-auth/AG6bxaw__UTLqwvr37cDb9ildEoRyEWUks5s_ny1gaJpZM4QvYDQ .
Uploaded to Nuget as well.
Hi, Im using your library with no problem form several months. Thanks for That!
From some days i have been issued this problem on executing client.Activities.GetAthleteActivitiesAfter
I'm try to send you a pull request with this type included, but a 403 received, so i created this issue
Error converting value "WaterSport" to type 'StravaSharp.ActivityType'. Path '[2].type', line 1, position 2989. at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType) 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.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) 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.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id) 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[T](JsonReader reader) at RestSharp.Portable.Deserializers.JsonDeserializer.Deserialize[T](IRestResponse response) at RestSharp.Portable.RestResponse
1.1.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 RestSharp.Portable.RestClientBase.<Execute>d__59
1.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 StravaSharp.ActivityClient.