NSURLErrorDomain Code = -1000 "bad URL": what does this mean?

I have this confusing error. I send JSON through the GET method, and the website will parse and display the data. The problem is that I get the error "NSURLErrorDomain Code -1000" or more simply "Bad URL". The fact is that when I check the server, the data that I sent is successfully parsed and displayed. Therefore, I am really confused why I get this "bad URL" error at all. Can someone help me?

Here is the error I get:

Domain Error = NSURLErrorDomain Code = -1000 "bad URL" UserInfo = 0xff73df0 {NSUnderlyingError = 0xff73810 "bad URL", NSLocalizedDescription = bad URL}

EDIT:

http://sample.com/imwebjson.php?sid=5amp13&job=sendNotes&im_flds={\"im_uid\":"1",\"im_bookid\":"57",\"im_pagenr\":"1",\"im_notes\":"Testing%5C%5Cn"} 

Well, you might ask why some parts of the JSON string are already encoded. These encoded parts are special characters. I realized that stringByAddingPercentEscapesUsingEncoding is very incomplete. It does not encode all special characters, and more importantly, when it encodes some special characters, the URL is not recognized at all. So I decided to manually encode the special characters in the string.

+4
source share
2 answers

Colon identifier : (at least, possibly others, such as " and { ) should be percent encoded in the URLs.

+4
source

In the GET parameters you need to change the spaces "for"% 20 "

0
source

Source: https://habr.com/ru/post/1414692/


All Articles