Remote xml/json API actually usable?


a customer asked me to create a daily report of accounts that have not changed their password for more than 90 days. I was thinking of setting up a cron job quickly, connecting to the remote API of Virtualmin Pro, gather data as xml/json and build that report.

The docs read:

If you would prefer JSON format output, add the json=1 parameter to the remote API call. Alternately, you can select XML format with the xml=1 parameter.

Well, what you get isn’t actually usable json nor xml but the plain text data wrapped into some trivial json/xml output. I expected to get meaningful data structures, with proper fields and attributes. I also expected some machine readable data format, not “5 GB” as a quota value but maybe 5368709120 (size in bytes). I did also expect http encoding headers in the response to properly transmit UTF-8 values. I was hoping for more attributes in the xml/json than what’s in the UI, like last-updated timestamps.

Was it so wrong to expect such things? It’s 2011 after all, everybody’s talking REST and json/xml data interfaces are common all over the place.



It sounds like you are missing the &multiline= URL parameter in the API calls - this is needed as well as json=1 in order to get JSON. I will update the docs to make this clearer …

Sorry that this is a little obscure … it is a side-effect of the way that the same underlying scripts are used for both shell and remote API calls to Virtualmin.