NSURL Bad Excess

I have error 1000 (URL bad excess) and I'm not sure what happened. An example URL looks something like this (which already has a percentage encoded as I read from Bad URL when requested using NSURL ):

 http://test1.test.com/X?op=find&base=tpl01&request=%28%28WCL=DVD%20or%20WCL=VCD%20or%20WCL=SDVD%29%20AND%20%28WFM=VM%29%20AND%20%28WIS=19%20or%20WIS=01%29%29 

However, I'm still not sure why it is not working.

If necessary (before percentage coding):

 http://test1.test.com/X?op=find&bas=tp01&request=((WCL=DVD or WCL=VCD or WCL=SDVD) AND (WFM=VM) AND (WIS=19 or WIS=01)) 

In my internet connection, I already registered request.URL , but it just turned out to be null. I inserted my url. Any help would be appreciated.

+4
source share
1 answer

EDIT: Encoding type stringByAddingPercentEscapesUsingEncoding may solve your problem

 NSString* urlText = @"http://test1.test.com/X?op=find&bas=tp01&request=((WCL=DVD or WCL=VCD or WCL=SDVD) AND (WFM=VM) AND (WIS=19 or WIS=01))"; urlText = [urlText stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSURL *url = [NSURL URLWithString: urlText]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:10]; [request setHTTPMethod: @"GET"]; NSError *requestError; NSURLResponse *urlResponse = nil; NSData *response1 = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&requestError]; 

Hope this helps

0
source

All Articles