I'm not sure you need to use ASIFormDataRequest.
Here's what I do:
- (void)doRequest:(NSURL *)url params:(NSDictionary *)dict
{
NSString *postData = [dict JSONRepresentation];
request = [[ASIHTTPRequest requestWithURL:url] retain];
[request setDelegate:self];
[request addRequestHeader: @"Content-Type" value:
@"application/json; charset=utf-8"];
[request appendPostData:[postData
dataUsingEncoding:NSUTF8StringEncoding]];
[request startAsynchronous];
}
Joseph
ASIFormDataRequest's appendPostString: is a private method that is used to help record information about the request body when DEBUG_FORM_DATA_REQUEST is turned on. There shouldn't normally be any reason to use it yourself.
As Joseph says, you shouldn't use an ASIFormDataRequest for this - a regular ASIHTTPRequest as in his example would be the best way to go. ASIFormDataRequest is only used when you want to do a multipart/form-data or url-encoded form post. In your case, you simply want to send the JSON as the request body, and appendPostData: is the preferred way of doing that.
Best
Ben
It should just work if you change the url.
If you have a self-signed certificate (or one where the certificate
authority is not present on the iphone) you will need to [request
setValidatesSecureCertificate:NO]. If you are worried about your app
being attacked that may mean you also need to verify that the
certificate returned is the correct one.
Beware that https can be a huge additional performance penalty for small requests when running on a 2G/GSM mobile network, so you may want to consider only using it for really sensitive requests.
Joseph