Ranjitsingh Chandel
Ranjitsingh Chandel

Reputation: 1489

Exception "Illegal character in query at index -" in Android

I am trying to send data on server using following link.

**WEBSERVICE LINK:**
http://75.125.237.76/post_reviews.php?data=text1

If I set data filed with single string (ex:data=text1), That time my try block in source code working fine, without any exception.

But When I set data field with multiple string with spaces (ex: data=text1 text2 text3), Then Exception generated i.e. Illegal character in query.

**EXCEPTION:**
Illegal character in query at index 75: http://75.125.237.76/post_reviews.php?data=text1 text2 text3

My question is Why exception generate when we use multiple strings (like: data=My name is xyz).

If I replace data field with single string that time is working fine.(data=xyz)

Upvotes: 3

Views: 9589

Answers (2)

Abubakkar
Abubakkar

Reputation: 15644

Encode space with %20 have a look at this one for more encodings

Upvotes: 9

kjurkovic
kjurkovic

Reputation: 4104

Encode your URI string so the spaces will be presented as %20

Upvotes: 2

Related Questions