Page 1 of 1

Force Route to Return XML

PostPosted: Thu Aug 06, 2020 4:30 pm
by SBarnes
Is there a way to force a specific route in ServiceStack to by default return XML rather than it needing to be specified in the request?

Re: Force Route to Return XML

PostPosted: Thu Aug 06, 2020 5:07 pm
by Scott.Pearce
I did a bit of research, and played around with the plugin code, but as far as I can tell you can't. You can of course set a default for ALL routes via "DefaultContentType" in the ServiceStack config (line 703 in the REST API plugin).

Try posing the question here, or maybe if you search those forums you will turn up something I missed.

EDIT:

One thing about mythz at ServiceStack is that he is usually pretty responsive if he sees a good use case for a feature request.

Re: Force Route to Return XML  Topic is solved

PostPosted: Thu Aug 06, 2020 5:11 pm
by SBarnes
Thanks Scott,

In the end I also figured that was the case myself, so I changed it to return a HttpResult and because the XML wasn't that hard put it in as a string and then added a header for the content type and the platform I am talking to was happy with that, not a pretty solution but it works.

Re: Force Route to Return XML

PostPosted: Mon Jan 18, 2021 6:40 pm
by SBarnes
Hi Scott,

I just found this https://docs.servicestack.net/formats whilst looking for something else, without having tried it, it appears you can do it.