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

Convey.WebApi - Special characters in the query string #46

Open
GwtLabs opened this issue May 24, 2020 · 0 comments
Open

Convey.WebApi - Special characters in the query string #46

GwtLabs opened this issue May 24, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@GwtLabs
Copy link

GwtLabs commented May 24, 2020

I'm sending a GET request to the Web API. If the first character in the value string is any of:

[{"

The query fails. Sample strings causing the problem:

asd"asd
[test
{asd

I get the error:

[21:42:40 ERR] Unexpected character encountered while parsing value: [. Path 'name', line 1, position 35.
Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: [. Path 'name', line 1, position 35.
at Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType readType)
at Newtonsoft.Json.JsonTextReader.ReadAsString()
at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
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.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 Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at Open.Serialization.Json.Newtonsoft.JsonSerializerInternal.Deserialize[T](String value)
at Convey.WebApi.Extensions.ReadQuery[T](HttpContext context)
at Convey.WebApi.EndpointsBuilder.BuildQueryContext[T](HttpContext httpContext, Func3 context, Action1 endpoint)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Convey.WebApi.Exceptions.ErrorHandlerMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)

There seems to be something wrong with replace here:

var serialized = serializer.Serialize(values.ToDictionary(k => k.Key, k => k.Value))

@GooRiOn GooRiOn added the bug Something isn't working label Nov 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants