我正在尝试使用 AFNetworking 调用 Rest API,但没有得到正确的响应字符串。这是我的代码:
NSURL *url = [[NSURL alloc] initWithString:@"https://www.ez-point.com/api/v1/ezpoints"];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
AFJSONRequestOperation *operation =
[AFJSONRequestOperation JSONRequestOperationWithRequest:request
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSLog(@"%@",@"testing");
NSLog(@"%@",operation.responseData);
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
NSLog(@"%@", @"Error");
}];
[operation start];
但我把它打印出来:
2013-10-29 08:31:08.175 EZ-POINT[4004:c07] testing
2013-10-29 08:31:08.175 EZ-POINT[4004:c07] (null)
正如你所看到的,它返回 null,我期待这个:
{"status": "user_invalid", "data": "", "token": "", "errors": ["user not found"], "user_id": ""}