Request non-XML data via Web.Network.createRequest
Hello all,
First off, good to see that gadget development forum on MSDN.
Anyway, what I am posting for is this: I'm trying to request normal plain text data (in non XML format) via the Web.Network.createRequest method. However, I can not find a Web.Network.Type type that represents regular data. I've tried XML, which responds with an "invalid xml" in the body of the response, and Stream throws an exception somewhere about not being able to load the target object. I haven't tried Script, CSS, Image, etc. but that probably won't work either because they are for specific purposes.
Is there a way to make it do cross-domain requests for regular, plain text data, or?
Is there some sort of bug in the proxy for Spaces, perhaps?
When I request an URL, say http://example.com/getId (which is a plain/text document) with the following code, it returns "xyz" just fine. However, if I create another page, say http://example.com/getIdForUrl and make it return the exact same string (xyz) with Content-Type set to plain/text then the callback suddenly gets a responseXml containing "Invalid XML".
The proxy shouldn't do any processing, right?
function DoRequest(uri, callback)
{
// Consume XML with the Live.com API (you gotta love it)
var request = Web.Network.createRequest(Web.Network.Type.XML,uri,{"proxy" : "generic"},callback);
request.execute();
}
All data returned from createRequest(Web.NetworkType.XML, ...) must have the content type text/xml. Unfortunately, we don't provide a mechanism for returning generic content to your gadget script. You will need to either host a wrapper that returns the text you need as XML or find another mechanism for retrieving your content. Your request for non-XML content worked in Spaces until a recently, but this was not intentional.
If you find a good solution to this problem, please post it back here to help out other developers in the same boat.
Thanks!
Hi Ben, I already posted another question but since this thread is also related I figured to post another question.
Where can I find the class definitions (member list) for the respone object that is passed back in the async callback for createRequest? I waned to see how I can manipulate the data for display and I don't seem to be able to find any relate docs.
Also, how does Web.Network.Type.Script work? Does it return a different object on the async callback?
I'm a total newbie so any help will be appreciated!
Thanks!
- KC.