I intend to post json data :
NSString *newJSON = [theDictionary JSONRepresentation];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:ADDRESS,action]];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request appendPostData:[newJSON dataUsingEncoding:NSUTF8StringEncoding]];
[request startSynchronous];
NSString *responseString = [request responseString];
NSMutableDictionary* responseDict = [responseString JSONValue];
NSLog(@"responseString = %@",responseString);
does the code work?did I miss some code?
I read the asihttprequest tutorial,and find it always post data with asiformdatarequest,what’s the difference between asihttprequest and asiformdatarequest,if I just want to post json data,what should I do?thank you in advance.
UPDATE:yes,it works,but don’t work well,I use some tool test the data,and receive some extra data:
POST / HTTP/1.1
Host: 192.168.0.113
User-Agent: Ushi.com/1.0 CFNetwork/548.1.4 Darwin/11.3.0
Content-Length: 58
You can post text data in json format like this
API itself sets user-agent although you can set it yourself too