I am implementing a forgetting password service in which I would pass an email address and it will return JSON to find out about the sent email. The problem is that I cannot read the response line in json, and my exception message shows that the data parameter is zero, but if I look at the URL in my web browser, the service looks fine as below. my code is:
NSURL *url = [LokalmotionCommonTask getURLForgotPassword:emailFieldTxt.text];
NSData* data = [NSData dataWithContentsOfURL: url];
@try {
NSError* error;
NSDictionary* jsonDict = [NSJSONSerialization
JSONObjectWithData:data
options:0
error:&error];
NSLog(@"%@", [jsonDict objectForKey:@"response"]);
}
@catch (NSException *exception) {
NSLog(@"forgot password exception: %@: %@", [exception name], [exception reason]);
}
and the response of the service that I get in my web browser is as follows:
{"status":400,"response":"Your request to change password is already sent. Please check your email."}
An exception:
forgot password exception: NSInvalidArgumentException: data parameter is nil
source
share