When I access my azure function (C# HttpTrigger
) from my browser I get an XML response with an error message instead of a JSON response.
That is to be expected, since the response contains, amongst others, a JObject, which can be serialized to JSON just fine, but not to XML, and the browser's Accept header asks to prefer XML over JSON.
I can use a workaround to get the correct response by fiddling with the browser's Accept header (inserting application/json;q=0.95
), but what I really want is to disable XML serialization in the Azure Function, since my function is not going to be XML compatible anyway.
Is there a way to remove or disable the XML formatter in Azure Functions so it "forgets" that it can serialize to XML, and any application/xml
in the request header is ignored? And instead make the JSON formatter take precedence, despite the request asking to prefer XML?