Re: Web API Accept type

2015-08-18 Thread Nelson
Hi Greg, Sounds like this is what you want: http://www.asp.net/web-api/overview/formats-and-model-binding/media-formatters You can define your own media formatter to customise your response for particular types Regards, Nelson Chan On 18 August 2015 at 20:04, Greg Keogh wrote: > I would pr

Re: Web API Accept type

2015-08-18 Thread Greg Keogh
> > I would provide two different methods. It's easier for you and easier for > the end developers to understand. > In the end I sort of did that. It's best not to fight the system, so I changed the method so that it simply returns a serialized object (a rather complicated one), but no matter what

Re: Web API Accept type

2015-08-17 Thread Davy Jones
I would provide two different methods. It's easier for you and easier for the end developers to understand. Davy Sent from my iPhone > On 17 Aug 2015, at 23:56, Greg Keogh wrote: > > Folks, in Web API when you sent an object back in the response it's > automatically serialized as JSON or XML

Re: Web API Accept type

2015-08-17 Thread Bec C
Is you "tweak" of the xml generic, ie. will happen to every xml response? If so I'd imagine the method would be to override the default xml serializer (or implement some interface) and tell web api to use your one instead of the default. Testing which one is active by any means just seems hacky. Or

Re: Web API Accept type

2015-08-17 Thread Greg Keogh
On 18 August 2015 at 08:28, DotNet Dude wrote: > Is this what you're after? > http://www.yasserblog.com/2013/07/mvc-web-api-customized-xml-output.html > This guy is reshaping the response XML by clever means which I have noted as useful in my memory banks. However, he knows he's responding with

Re: Web API Accept type

2015-08-17 Thread DotNet Dude
Is this what you're after? http://www.yasserblog.com/2013/07/mvc-web-api-customized-xml-output.html On Tue, Aug 18, 2015 at 7:56 AM, Greg Keogh wrote: > Folks, in Web API when you sent an object back in the response it's > automatically serialized as JSON or XML depending upon the Accept header.

Web API Accept type

2015-08-17 Thread Greg Keogh
Folks, in Web API when you sent an object back in the response it's automatically serialized as JSON or XML depending upon the Accept header. This is great, but I have to cheat the system slightly and send back manually tweaked XML only if the XML serializer is "active". Rather than look at the raw