Search code examples
xmldjangojsonposttastypie

Tastypie POST XML returns json


I have a resource that needs to accept POST requests serialized as XML. The resource needs to return the full object upon post. Therefore i set

always_return_data = True

I am able to successfully post data but the response is always JSON. I tried setting the serializer to be XML only, by stating

serializer = Serializer(formats=['xml'])

but i still get the response in JSON.

Has anyone seen this and solved it?


Solution

  • Ok, so the answer was pretty easy and obvious…

    Simply add

    ?format=xml
    

    to the URL (even when using POST) and the response and content type will be XML as well