I have an iPhone application through which I call asp.net webservice with json. It works fine with all data. But when I try to & in any data it throws server error as below
System.ArgumentException: Unterminated string passed in. (55): {"UserId":"somebody@somebody.com","FirstName":"somebody
at ProjectName.ProjectWebService.AuthenticationService.UserRegistration(String jsonText) in C:\Users\mkariya\documents\visual studio 2010\Projects\ProjectName\ProjectNames\MeaNexusWebService\AuthenticationService.asmx.cs:line 555
Data which I passed to this web service is as below
“UserId”:”somebody@somebody.com”,”FirstName”:”somebody&fname”,”City”:”Ahmedabad”,”LastName”:”somebodylname”,”State”:”Gujarat”,”Country”:”India”,”Password”:”admin1!”}
in which FirstName has value somebody&fname, so issue occurs at that place.
You need to escape the ampersand. Use the following instead of the “&” character: