I have been provided with a REST
service from my customer for which I should get JSON
response for my iOS code.I am using content-type
as "application/json" but somehow it is taken as "text/html" by default. I cross checked this in a REST
client in my Mozilla browser using "application/json" for the content-type
in header section and I could see the proper response.On using the below code, I am getting a 400
error from the server. I could always see "text/html" as being used as part of the 400
response by default
NSString * strBodyOnlineStart = [NSString stringWithFormat:@"&email=***@***.com&deviceCode=*****&password_value=***"];
NSURL *urlOnlineStart = [NSURL
URLWithString:@"http://local.server/xxxxx"];
NSMutableURLRequest *requestOnlineStart = [NSMutableURLRequest
requestWithURL:urlOnlineStart];
[requestOnlineStart setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[requestOnlineStart setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[requestOnlineStart setHTTPMethod:@"POST"];
NSData *requestBodyOnlineStart = [strBodyOnlineStart
dataUsingEncoding:NSUTF8StringEncoding];
[requestOnlineStart setHTTPBody:requestBodyOnlineStart];