-1

I am sending a json formatted data to the server. My data looks like this :

...
{"AvatarTimeStamp":"0","ContactPhoneNumber":"123456789124"},
{"AvatarTimeStamp":"0","ContactPhoneNumber":"123456789124"}, 
...

when i send this data to the server, i am getting 400 response code. I thought that there might be an issue with my data having some special character which is causing the bad request.

Normally we in our phone book we have phone numbers in different formats like having brackets , plus signs, spaces etc...

If i am thinking in the right way then kindly tell me is there any way to remove all these kind of characters that may cause bad request. If i am thinking in the wrong direction then kindly guide me. Thnx.

EDITED: All my procedure is working fine on almost 99 % android devices or i say 99 % contact books. This is happening on really few devices like S4 mini.

Ali Ansari
  • 221
  • 3
  • 13

2 Answers2

0

You can use replace function on string. someString.replace("}", ""); this will remove } from your string. Some special chars you will have to escape like ^, . etc. someString.replace("\\^", "");

Milkmaid
  • 1,569
  • 3
  • 22
  • 36
0

use this to remove any extra character other than phone number(Digits):

number.replaceAll("\\D", "");
dvs
  • 574
  • 4
  • 14
  • sure...don't forget to check the answer as correct if it solves your problem..have a good day :) – dvs Feb 18 '15 at 06:24