Unsupported URL in NSURLRequest

ghostrider picture ghostrider · Nov 29, 2013 · Viewed 57.3k times · Source

If I run this request from my terminal I can see the JSON requests as normally:

curl -XGET 192.168.0.6:8888/scripts/data/backend2/index.php/name/_all

My code for the NSURlRequest is this:

 NSURLRequest *request = [NSURLRequest requestWithURL:
                             [NSURL URLWithString:@"192.168.0.6:8888/scripts/data/backend2/index.php/name/_all"]];

    [[NSURLConnection alloc] initWithRequest:request delegate:self];

And I am getting this error:

didFailWithError
2013-11-29 22:31:08.164 Ski Greece[607:a0b] Connection failed: Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo=0xcd042d0 {NSErrorFailingURLStringKey=192.168.0.6:8888/scripts/data/backend2/index.php/name/_all, NSErrorFailingURLKey=192.168.0.6:8888/scripts/data/backend2/index.php/name/_all, NSLocalizedDescription=unsupported URL, NSUnderlyingError=0xdbdcc70 "unsupported URL"}

How can I make the call to that URL? I cannot access the server code - I know it is just setup to return me what I need, if I call that URL?

Answer

Vizllx picture Vizllx · Nov 30, 2013

Try to include appropriate url scheme to your url, e.g.

[NSURL URLWithString:@"http://www...