How to make Http Post Request using JSON. I tried every option which is available on Internet.But could not get the Data. So please post entire code to make a request.
Here's a basic example of NSURLConnection POST-ing JSON to an URL.
- (void)performRequest {
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://someplace.com/"]];
[request setValue:@"Some Value" forHTTPHeaderField:@"Some-Header"];
[request setHTTPBody:@"{\"add_json\":\"here\"}"];
[request setHTTPMethod:@"POST"];
[NSURLConnection connectionWithRequest:[request autorelease] delegate:self];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
// Fail..
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
// Request performed.
}