I am working on an iphone app and my requirements are to make a simple post to a web service and the web service returns a json response.
The sample code they give for a post is this, but how do I get a response? I see there is asynchronous code for doing a get, but how do I do it async for a post?
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request addPostValue:@"Ben" forKey:@"names"];
[request addPostValue:@"George" forKey:@"names"];
This you use for posting a synchronous response, the response will be in the var "response".
To make a async request, do the following:
Basically the request finished will be called when there is data, depending on the format you can get either a NSData or a NSString like in the example.
Your params you can put in like you said yourself:
I have used a normal type of requesting, you could replace the ASIHTTPRequest class with ASIFormDataRequest.
If you're targeting iOS 4+ you can use blocks, which makes asynchronous code a little bit nicer. You won't have to deal with delegates.
More about blocks http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/Blocks/Articles/00_Introduction.html