I am calling the following URL from my iPhone app
NSString *resourcePath = [NSString stringWithFormat:@"/sm/search?limit=100&term=%@&types[]=users&types[]=questions", searchTerm];
However, when the server call is made, I found that the actual URL sent was this
/sm/search?term=mi&types%5B%5D=questions&limit=100
How can I resolve this so that the correct URL is sent to the server?
I assume that you use the
NSURLmethodto create the URL. According to the documentation, this method automatically escapes path with the
stringByAddingPercentEscapesUsingEncoding:method.The square brackets are escaped, because they are “unsafe” in the sense of RFC 1738 – Uniform Resource Locators (URL):
If you create the URL with
then no escape sequences are added, because
initWithStringexpects the string to contain any necessary percent escape codes.