Hi all --
I have an API controller that receives data from several outside services (more property, several outside devices, I guess) via a POST request to a REST endpoint. When I started this project a looong time ago all of the devices were sending XML, so later when a few started needing Json it made more sense to hack in support for that and move on to the next thing. My controller routes POST requests to a parameterless method that looks at the Content-type header and calls an appropriate unpacker to return a data object, which is the same regardless of how the data arrives.
The decisions all made sense at the time, and I was a much less skilled programmer at the time I started this. I probably wouldn't do it this way today.
The current problem is this:
Over the years, I've built (as I'm sure most everyone has) a framework that I use for most of my projects. Web API's built-in unpacking of Json and x-www-form data route a data object to a generic POST method, and I have other methods that would live on other endpoints when XML or form-data are needed. This has worked really well over the years, Xml and form-data have become such outliers that it's not a problem -- except with this project.
So here's my question -- From all the research that I've done there are two ways that Web API will unpack XML data (cleanly) and deliver a valid data object to Post(dataObject item), exactly the same as it does for Json and x-www-form right now:
This isn't my only reference on the matter, but summarizes my understanding pretty well: https://stackoverflow.com...ith-xml-data-on-post
Anyone have any insight? It is entirely possible that I'm missing something huge here, I'm a solo coder and largely self-taugh on anything newer than Turbo Pascal and Turbo C++ for Windows 95, so sometimes all I need is someone to show me which boat I've missed...
If the right answer is that I either need two endpoints at distinct urls or just keep doing it the hacky way I am doing it, I can probably just accept that and move on. I just have a hard time giving up the fight without knowing for certain there's no way to do it.
Thanks in advance -- -Tim
These Forums are dedicated to the discussion of DNN Platform.
For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:
Awesome! Simply post in the forums using the link below and we'll get you started.