-
-
Notifications
You must be signed in to change notification settings - Fork 380
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
GetJsonAsync<T> is not working after upgrading the Flurl Http to version 4 >= #824
Comments
Please provide a minimal example of something that won't deserialize as it did in 3.x. Using Flurl.Http.Newtonsoft should absolutely be the key to it working exactly the same. |
Same issue I am also facing. Everything is working fine version 3.2.4 but when we upgrade it stops deserializing using GetJson method. It happening only when we use PostJsonAsync() method. Working fine for PostUrlEncodedAsync() method. Seems to me issue with the response from PostJsonAsync |
I was seeing the same issue with .GetJsonAsync(). JSON returned from an odata endpoint doesn't get de-serialized correctly. Calling code: var odataResult = await "https://domain.com"
.AppendPathSegment("/odata/Entities")
.WithOAuthBearerToken("token-value")
.GetJsonAsync<OdataResponse<MyDTO>>();
private class OdataResponse<T>
{
public IEnumerable<T> value;
}
private class MyDTO
{
[Key]
public Guid Id { get; set; }
public string Name { get; set; }
public string Route { get; set; }
public bool Default { get; set; }
public string Metadata { get; set; }
} Changing code to use Flurl.Http.Newtonsoft helps with this issue: var odataResult = await "https://domain.com"
.AppendPathSegment("/odata/Entities")
.WithOAuthBearerToken("token-value")
.WithSettings(settings =>
{
settings.JsonSerializer = new NewtonsoftJsonSerializer();
}
)
.GetJsonAsync<OdataResponse<MyDTO>>(); Response returned by the odata endpoint: {
"@odata.context": "http://domain.com/odata/$metadata#Entities",
"value": [
{
"Id": "d1ebc584-038a-4dbd-f06c-08dc8fbf81d1",
"Name": "My second entity",
"Route": "werthjk",
"Default": false,
"Metadata": "{\"name\":\"My second entity\",\"route\":\"werthjk\",\"description\":\"Testing creation\",\"default\":false,\"extras\":\"[]\"}"
}
]
} Package versioning: |
Same approach we have used |
I have used the below code in DI to get it to work again: FlurlHttp.Clients.WithDefaults(builder => |
I have recently upgraded my Flurl Http from 3.2.4 to 4.0.2.
Post upgrading, my test cases start failing when deserializing it to a type. I have also verified the issues while running the app locally.
To check the deserialization issue, I have explicitly deserialized the Json to a given type using JsonConvert.Deserializer() which works perfectly.
When I downgrade the version to 3.2.4 everything starts working normally.
Can someone please verify the issue? Thanks
Package versioning:
Flurl: 4.0.0
Flurl.Http: 4.0.2
The text was updated successfully, but these errors were encountered: