Reputation: 1
I have used a lot time on trial-and-error for the makeWebRequest function. Using a very simple service it works for JSON, but not for XML.
var url = "http://www.broadbandmap.gov/broadbandmap/demographic/jun2014/nation";
// WORKS
Comm.makeWebRequest(url, {"format" => "json"}, {}, method(:onReceive));
// FAILS for XML with responseCode "Failed to load Error: -400"
Comm.makeWebRequest(url, {}, {}, method(:onReceive));
For the XML scenario I have tried all sorts of different options, but always fails. Anyone who can make an working example?
Upvotes: 0
Views: 1670
Reputation: 977
Should XML be even supported? From what I gather from the documentation, it is not:
:responseType (Number) — The format of the response. Should be a HTTP_RESPONSE_CONTENT_TYPE_* value. If not given, the system will attempt to first parse the response as JSON, then as URL ENCODED.
XML is never even mentioned on the page.
If that is indeed the API you wish to use (and not just an example), is there any reason you can't request and process response in JSON format?
http://www.broadbandmap.gov/broadbandmap/demographic/jun2014/nation?format=json
Upvotes: 0