Giter VIP home page Giter VIP logo

Comments (5)

alexandery avatar alexandery commented on July 25, 2024 1

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.

tmenier avatar tmenier commented on July 25, 2024

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.

njadhavparcelvision avatar njadhavparcelvision commented on July 25, 2024

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.

njadhavparcelvision avatar njadhavparcelvision commented on July 25, 2024

Same approach we have used

from flurl.

mwasif7 avatar mwasif7 commented on July 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.