Question

I'm busy with web service and an iOS app. So far I haven't had that many issues. However, there is a web service that needs the final URL request to be in a certain format. Something along the lines of:

...?IncludedUserIds[]=1357213,286476&..

These parameters are constructed from an NSDictionary and NSString. Now when I add the comma - the end URL that makes the request ends up like this:

..?IncludedUserIds=%5B%5D1357213%2C286476&...

It seems that AFNetworking 2.0 has converted the square brackets into =%5B%5D and the comma into: %2C

Obviously, the web service has no idea what this means and fails.

Is there a way to keep the final Url as I need it to be? Why do these conversions happen and where can I learn more about this sort of thing?

Was it helpful?

Solution

AFNetworking keep the final url encoded, that is the best way, since you could have special characters in you query string that could break all. Instead, you should decode the url server side, for example in PHP you have methods, like urldecode or rawurldecode (eg: 'foo%20bar%40baz' ->'foo bar@baz'), or in ASP it should be kept automatically.

Hope it helps

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top