-1

Getting the following error while using JSONMODEL to hit a web service.

"Error Domain=JSONModelErrorDomain Code=2 "Bad network response. Probably the JSON URL is unreachable." UserInfo=0xa1aeea0 {NSLocalizedDescription=Bad network response. Probably the JSON URL is unreachable.}"

Here is my Code

NSDate *currentDate=[NSDate date];
NSDictionary *dict=[NSDictionary dictionaryWithObjectsAndKeys:@"100",@"userId",@"ios",@"platform",currentDate,@"currentDate",@"1",@"numberOfPage",@"10",@"numberOfRowToFetch",@"1",@"category",nil];
NSString  *urlStr=[@"http://www.lptpl.tk/teleshka/admin/index.php?r=jsoner/homeProductList" stringByReplacingOccurrencesOfString:@" " withString:@""];
[JSONHTTPClient postJSONFromURLWithString:urlStr params:dict completion:^(id json, JSONModelError *err){
    LoginDataModelClass *responce = [[LoginDataModelClass alloc] initWithDictionary: json error:nil]; 
   [[NSNotificationCenter defaultCenter] postNotificationName:Login_Responce object:responce];
}];

2.Following error occured while passing body string.

"The certificate for this server is invalid. You might be connecting to a server that is pretending to be “lptpl.tk” which could put your confidential information at risk."

Sourabh Sharma
  • 8,222
  • 5
  • 68
  • 78
  • Can you show your code to reach the web service? – Claudio Redi Jun 24 '15 at 13:14
  • Your Error is already stating that the URL is unreachable, have you tried accessing it in browser? – saurabh Jun 24 '15 at 13:15
  • Please add more detail. What service are you trying access, what exactly are you posting to the service, and do they give any more details as far as what their error codes mean? – Adam Jun 24 '15 at 13:21
  • its working fine if web service is built in cake PHP framework,but getting the above error if web service is built in YII framework. please reply asps.Thanks – rohit chauhan Jun 24 '15 at 13:21
  • I assume you are making an HTTP request to this web service. Try using a tool like Fiddler to see exactly what you are sending and what the server is returning. – Adam Jun 24 '15 at 13:23
  • Why are you using `stringByReplacingOccurrencesOfString` on a string literal that contains no spaces anyway? – Droppy Jun 24 '15 at 13:30
  • 1
    Also I get: `HTTP request sent, awaiting response... 200 OK Length: 0 [text/html]`. – Droppy Jun 24 '15 at 13:31
  • i have tried by trimming the space also. – rohit chauhan Jun 24 '15 at 13:34

1 Answers1

0

I solved it by my own.Problem was that i was passing a date type parameter, while json model only support either String Type or number Type parameters.