请求是:
{
"MyNumber" : "1",
"MyMessage" : "C1LdbQ6MCyPMiYnmM7STZl5gJIROmHdOA\/1EXOwkXWf9jBLvuTyDR092WF29Zctv78kafx0pNBcguV5Cc+u72MmneL\/z2\/O9a9O0I85l0iPG4TZMwS+jVYy2hxZWB8iuI5cnpdF5LreI5T9hFKp5S8HfD4ChCqcrW0R4QAZKrSWhviAIts3MGw3wkw0LdEPK"
}
回应应该是:
D1491810C63C7AB29EAF14CCF90158C5B71F43E0DBCBB44EA4739E3258A7C0FF624045EFEAFE43722481F214AE34D48D6A0787422144C83D1C1E13626ADAD374
代码:
NSURLSessionDataTask *datatask = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *connectionError)
{
if(connectionError)
{
NSLog(@"Connection error :%@",connectionError);
failedBlock (connectionError);
}
else
{
//Here I am getting response
NSLog(@"Response data is :%@",[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding]);
NSError * error = nil;
//Here I am getting error Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.}
NSString * responseData = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&error];
if(error)
{
failedBlock(connectionError);
}
else
{
successBlock (responseData);
}
}
}
];