Basically I want to set
Content-Type: application/json;
in order to call a dot net web service and have it return json to an iphone application.
At the moment I have
NSString * jsonres = [[NSString alloc] initWithContentsOfURL:url];
What do I need instead in order to issue a blocking request ?
You need to use NSURLMutableRequest, here you can add headers for content-type and the sort, here is a r eference, http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSMutableURLRequest_Class/Reference/Reference.html#//apple_ref/occ/cl/NSMutableURLRequest, once you set up your request you can add the value using this method - (void)addValue:(NSString *)value forHTTPHeaderField:(NSString *)field something like
[request setValue:@"application/json; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With