Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I just want to hit URL : http://kiascenehai.pk/rest_api/todayEvents/api-key/Of7NU7Jimh665D5G5VwO2eKO69sWv9lf/format/json and parameter is city_id.i.e: /city_id/1 but; compiler creates Error

Domain=NSURLErrorDomain Code=-1002

 "unsupported URL"

 or
 error 300;

so what shall be best way to pass arguments in a method in objective c???it also causes Error Domain=kCFErrorDomainCFNetwork Code=303 "The operation couldn’t be completed.

(kCFErrorDomainCFNetwork error 303

It will be pleasure for me if any one can reply me fast as possible.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
154 views
Welcome To Ask or Share your Answers For Others

1 Answer

Unable to reproduce issue you have mentioned, Probably the issue 'll be not because of the URL or parameters you used.

This is one of the best way to handle GET web service call and parsing data from the response, here i implemented the web call with your URL and params,

// Server data fetch
- (void)getDataForCityId:(NSInteger)cityId
{
    NSMutableString *urlString = [@"http://kiascenehai.pk/rest_api/todayEvents/api-key/Of7NU7Jimh665D5G5VwO2eKO69sWv9lf/format/json/city_id/" mutableCopy];
    [urlString appendFormat:@"%d", cityId];

    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:10.0];
    [request setHTTPMethod:@"GET"];

    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError)
     {
         if (data)
         {
             id jsonObj = [self parseJSON:data];
         }
     }];
}

// Method parses the JSON Data Received
- (id)parseJSON:(NSData *)data
{
    id jsonData = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
    return jsonData;
}

The jsonObj parsed form the response is asenter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...