I’m using SBJson Parser
this one
I’ve this JSON value, it’s a valid JSON, but still I get this error
-JSONValue failed. Error trace is: (
"Error Domain=org.brautaset.JSON.ErrorDomain Code=3 \"Unrecognised leading character\" UserInfo=0x63726a0 {NSLocalizedDescription=Unrecognised leading character}"
{
"Account": {
"LoginName": "My Name",
"Name": "My Name"
},
"UseInvoiceAddressAsDeliveryAddress": "true",
"InvoiceAddress": {
"Zip": "16444",
"CountryId": "1",
"City": "SSSS",
"Line2": "8",
"Line1": "Street 4"
},
"Phone": "12345678",
"FirstName": "My",
"LastName": "Name",
"Email": "sample@example.com",
"CellPhone": "234254233"
}
Here’s my code, I think I get this JSON error, because I’m not specifying any content type, I’m doing this but still it doesn’t work
SBJsonWriter *writer = [[SBJsonWriter alloc] init];
NSString *jsonConvertedObj = [writer stringWithObject:customerObject];
NSLog(@"The converted JSON String .... %@",jsonConvertedObj);
NSData *postData = [jsonConvertedObj dataUsingEncoding:NSASCIIStringEncoding];
NSMutableData *myMutablePostData = [NSMutableData dataWithData:postData];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:myURL];
[request setRequestMethod:@"POST"];
[request setClientCertificateIdentity:identity];
[request setValidatesSecureCertificate:NO];
[request addData:myMutablePostData withFileName:@"" andContentType:@"application/json" forKey:@""];
[request startSynchronous];
And this is the error I receive from the server :
The server encountered an error processing the request. The exception message is 'The incoming message has an unexpected message format 'Raw'. The expected message formats for the operation are 'Xml'; 'Json'. This can be because a WebContentTypeMapper has not been configured on the binding.
I’ve solved it myself, this is what solved it …
As suspected, I was using the wrong HTTPRequest type, and then I was not setting up the content type.