Open MonkAlex opened 3 years ago
@MonkAlex application/xml only works for xml metadata, all other odata payload, JSON is the only output format. That's the OData v4 spec format.
I am wondering the reason why "When i send request with Accept header application/xml, server send me xml answer.". I do think the result you got is plain XML format, not the OData v3 ATOM format. If you can share part of your xml result, it might be better for us to invesitage.
For first project add this code:
var formatters = ODataMediaTypeFormatters.Create();
config.Formatters.InsertRange(0, formatters);
And result:
<JobTitle xmlns:i="..." xmlns="...">
<Id>2</Id>
<Name>SomeName</Name>
<Status>Active</Status>
</JobTitle>
It relatively works, but only by formatting responses in XML. And even in this case response has neither xml standard header nor other atompub structure. As for POST request body - I didn't succeed forcing my OData service to accept body in XML format - it just does not parse it without any failures. I simply got null in my ODataActionParameters.
Did you find the solution to your problem? cause I'm having the same issue.
Want to get xml answer from odata server on aspnet core.
Assemblies affected
Microsoft.OData.Core 7.7.1 Microsoft.AspNetCore.OData 7.5.0
Reproduce steps
I have old project with odata packages:
When i send request with Accept header application/xml, server send me xml answer.
Now, i create new project with crossplatform aspnet core, packages:
Microsoft.AspNetCore.OData references to Microsoft.OData.Core 7.7.1, so i think no critical changes in work.
But when i try to get answer from server in xml format, always get JSON. Try to send application/atom+xml, try to add to request $format=xml, nothing changed, always JSON format.
Expected result
Accept header work as old aspnet.
Actual result
Accept header ignored.
In odata.net repo
https://github.com/OData/odata.net/issues/1908