-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
Alba's built in JSON serialization isn't working for oData endpoints #116
Comments
Pretty new to Alba, however I have been using it successfully against OData endpoints with the AspVersioning library. I think there is a bit of a nuance, I'm using [email protected]. Although the OData requests go through controllers, the serialization aligns with the MinimalApiStrategy. In the AlbaHost constructors, the input/output formatters are of type ODataInputFormatter and ODataOutputFormatter, so the MvcStrategy is initialized.
So the DefaultJson is then set to the MvcStrategy and I guess OData isn't a fan. I have not really tested this against the library, I just grabbed the source and hacked in a couple overloaded constructors and For<>... methods and so far things have been working. Not sure if this helps anyone, or not, but I too had the pleasure of banging my head against the wall with the Asp.Versioning and OData libraries so thought I'd post just in case! |
@ticky74 Would you mind sharing your Hack? |
I've ran into same issue. Our project has a mix of OData and API controllers. await fixture.Host.Scenario(x =>
{
x.Post
.Json(new { name = DocumentName, body })
.ToUrl("/documents/wiki");
x.StatusCodeShouldBeOk();
}); Throws this error:
A temporary workaround that seems to be working for us is to fall back to using using var httpClient = fixture.Host.GetTestServer().CreateClient();
var response = await httpClient.PostAsync("/documents/wiki",
JsonContent.Create(new { name = DocumentName, body }));
response.EnsureSuccessStatusCode(); A proper fix might require some effort to pick up the right formatter depending on individual request... |
More research necessary
The text was updated successfully, but these errors were encountered: