Comments (5)
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:
Flurl: 4.0.0
Flurl.Http: 4.0.2
from flurl.
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.
from flurl.
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
from flurl.
Same approach we have used
from flurl.
I have used the below code in DI to get it to work again:
FlurlHttp.Clients.WithDefaults(builder =>
{
builder.UseNewtonsoft();
});
from flurl.
Related Issues (20)
- client.Configure in 4.0.0 version? HOT 8
- Add `bool IFlurlClientCache.TryGet(string name, out IFlurlClient client)` HOT 1
- How can I speed limit when upload file HOT 1
- HttpTest WithRequestJson does not use JsonSerializer set on FlurlClientCache HOT 3
- Deadlock (or something weird) when calling `GetStringAsync` HOT 2
- 4.0.0 HOT 2
- System.EntryPointNotFoundException on PostJsonAsync HOT 1
- Add support for CancellationToken in IFlurlResponse asynchronous methods HOT 1
- Add option to disable conversion of plus signs to spaces for query parameters HOT 3
- According to RFC-7578 the Content-Disposition filename* parameter in multipart MUST NOT be used
- IFlurlClientBuilder.AddMiddleware cuts the chain of delegating handlers HOT 1
- Encode Issue HOT 2
- .net 8 blazor wasm PlatformNotSupportedException HOT 7
- The response ended prematurely HOT 2
- Trimming unused code causes the exception - Response could not be deserialized to JSON HOT 4
- Not able to configure Delegating handler in Flurl clientless DI configuration HOT 2
- Collection was modified; enumeration operation may not execute. HOT 1
- DownloadFileAsync => GetFileNameFromPath does not respect redirects HOT 1
- `OnRedirect` does not work with custom `HttpClient` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flurl.