I am posting json data to .net webservice. I am using below code.while checking in webservice it shows MessageValue:Failed.
-(void)sentSignUpDetails { NSLog(@"sentSignUpDetails.......");
NSString *jsonRequest = [NSString stringWithFormat:@"{\"UserName\":\"%@\",\"Password\":\"%@\",\"DeviceToken\":\"%@\"}",self.emailtextfield.text,self.passwordtextfield.text,appDelegate.Devicetoken];
NSLog(@"jsonRequest is %@", jsonRequest);
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://brewedlife.testshell.net/Brewedlife/AppSignup"]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
NSLog(@"1239");
NSData *requestData = [NSData dataWithBytes:[jsonRequest UTF8String] length:[jsonRequest length]];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:[NSString stringWithFormat:@"%d", [requestData length]] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody: requestData];
con = [NSURLConnection connectionWithRequest:request delegate:self];
}
- (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data1
{
if (!data)
{
data = [[NSMutableData alloc] initWithData:data1];
}
else
{
[data appendData:data1];
}
} It gets json failed error as below -JSONValue failed. Error trace is: ( "Error Domain=org.brautaset.JSON.ErrorDomain Code=3 \"Unrecognised leading character\" UserInfo=0x15e880 {NSLocalizedDescription=Unrecognised leading character} Please give any idea.Thanks