Wednesday, 18 September 2013

Obscure ASP.Net MVC4 WebAPI XML POST parameter

So I had this problem with getting simple XML to be recognized by a Web API controller.

The type that has no namespaces, the type that people cook up in a couple of minutes in Javascript then try to post to a RESTful API.

I started with switching to the XmlSerializer... http://stackoverflow.com/a/11804373/573261. Result is as follows:
System.InvalidOperationException: No MediaTypeFormatter is available to read an object of type 'Job' from content with media type 'application/xml'
I also tried changing the XML (body content) on the fly... http://stackoverflow.com/q/14365953/573261

In between those two attempts were others that you would rather not want to know about, since they obviously led nowhere.

In the end, it turns out that the XML Serializer cannot handle interfaced properties.

        public IList<Item> Items { get; set; }    // fails
        public List<Item> Items { get; set; }    // works

Now you know.

Monday, 19 March 2012

Must have tool - PhpMiniAdmin

So I sit here with a problem.
I have full FTP access to a PHP site, but no access to the MySQL database.
This must be simple, I think - the PHP code can already see it, so let's install phpMyAdmin?
This is when a simple search on Google led me to a wonderful utility - the type I like best, i.e. small and lightweight (29 kB) - phpMiniAdmin (SourceForge)
It has all the bang and wonderful utility of phpMyAdmin, without the 11 MB footprint!
Duly filed away in my Swiss knife folder, truly a must have for remote PHP/MySQL developers.