IOS passing backslash as part of url parameter to Json Web Service -


i'm calling json web service wich expects 2 parameters. username , password. username i'm trying pass includes backslash (\) domain account eg. companyname\jamesd.

here code.

nsstring *sname = @"companyname\\jamesd";  nsstring *url = [nsstring stringwithformat:@"http://checkin.companyname.com:2002/checkin.svc/checklogin?username=%@&password=pass",sname]; 

problem backslash somehow removed when calling web service -

i use nslog(...) output request looks -

<nsurlrequest http://checkin.companyname.com:2002/checkin.svc/checklogin?username=companynamejamesd&password=pass> 

i'm trying find out how can force include backslash in http request username.

like mike weller stated in comment have url-encode arguments. should use stringbyaddingpercentescapesusingencoding: method of nsstring after create url string like:

nsstring *url = [nsstring stringwithformat:@"http://checkin.companyname.com:2002/checkin.svc/checklogin?username=%@&password=pass",sname]; url = [url stringbyaddingpercentescapesusingencoding:nsutf8stringencoding];  

you can change encoding want, check ios encoding on apple docs

also make sure adding backslash when you're creating url string.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -