-
Notifications
You must be signed in to change notification settings - Fork 92
Open
Description
Hello, I would like to report an issue with I'm having while using OsmSharp.Api
In file OsmJsonConverter I'm getting following exception:
System.Text.Json.JsonException: The JSON value could not be converted to OsmSharp.API.Osm. Path: $ | LineNumber: 0 | BytePositionInLine: 16.
---> System.InvalidOperationException: Cannot get the value of a token type 'String' as a number.
at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_ExpectedNumber(JsonTokenType tokenType)
at System.Text.Json.Utf8JsonReader.TryGetDouble(Double& value)
at System.Text.Json.Utf8JsonReader.GetDouble()
at OsmSharp.IO.Json.Converters.OsmJsonConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
--- End of inner exception stack trace ---
at RestSharp.ResponseThrowExtension.ThrowIfError[T](RestResponse`1 response)
at RestSharp.RestClientExtensions.GetAsync[T](IRestClient client, RestRequest request, CancellationToken cancellationToken)
at Api.DevelopmentClient.GetVersion() in /home/flm/Work/learning/OsmSharpApi/Api/DevelopmentClient.cs:line 23
at Program.<Main>$(String[] args) in /home/flm/Work/learning/OsmSharpApi/Playground/Program.cs:line 2
at Program.<Main>(String[] args)
Exception is triggered here:
switch (propertyName)
{
case "version":
osm.Version = reader.GetDouble();This is how I call endpoint:
public class DevelopmentClient
{
private const string DEVELOPMENT_URL = @"https://master.apis.dev.openstreetmap.org/api";
private readonly RestClient _client;
public DevelopmentClient()
{
var options = new RestClientOptions(DEVELOPMENT_URL);
_client = new RestClient(options);
}
public async Task<double?> GetVersion()
{
var req = new RestRequest("versions");
var osm = await _client.GetAsync<Osm>(req);
return osm.Version;
}
}And this is plain response:
{
"version": "0.6",
"generator": "OpenStreetMap server",
"copyright": "OpenStreetMap and contributors",
"attribution": "http://www.openstreetmap.org/copyright",
"license": "http://opendatacommons.org/licenses/odbl/1-0/",
"api": {
"versions": [
"0.6"
]
}
}Metadata
Metadata
Assignees
Labels
No labels