Question in brief: In Dashcode 3.0, how do I tell a Data Source to send a POST request like:
url:
https://example.com/xml
method:
POST
HTTPBody:
<?xml version='1.0'?>
<request command='list'>
<parameter keyword='id' value='trogdor' />
</request>
The new Dashcode 3.0 in Snow Leopard is fantastic. I'm especially excited about "data sources" -- where you can provide a URL that returns XML or JSON. Dashcode fetches the data, then allows you to draw connections between pieces of the response and your UI -- much like Interface Builder.
All of the examples I've found use an HTTP GET request. But my feed must be accessed via POST. The DC.AjaxController has a "method" attribute -- easy to set to POST. It also has a "parameters" attribute -- to mimic a form-based post. The trouble is, my request is not from a form. I'll describe what I have working in Objective-C. I'd like to make the same thing work as a Dashboard and Safari widget.
NSMutableURLRequest *theRequest=[NSMutableURLRequest
requestWithURL:[NSURL URLWithString:@"https://example.com/xml"]];
[theRequest setHTTPMethod:@"POST"];
NSString *postString =
@"<?xml version='1.0'?><request command='list'><parameter keyword='id' value='trogdor' /></request>";
[theRequest setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
It would be ok to do it manually -- I don't have to use the whiz-bang Dashcode 3.0 visual connections, but it would be fun.