I want to append a list list_id=[11111,2222,3333]
to url it should look like below
http://1abc/spm//lookup/ids/xyz?list_id=[11111,2222,3333].
what should be the best and easiest way to do it ?
I want to append a list list_id=[11111,2222,3333]
to url it should look like below
http://1abc/spm//lookup/ids/xyz?list_id=[11111,2222,3333].
what should be the best and easiest way to do it ?
It is good to use http POST type request to deal with this kind of input data.
To send special characters in a query parameter url encoding is used.
URL encoded URL will look like below. http://1abc/spm//lookup/ids/xyz?list_id=%5B11111%2C2222%2C3333%5D
Usually servers are supposed to handle url encoding.
a) First, you need to understand that http supports sending the same parameter multiple times to constitute a list. You case is not new. This is how it normally would appear:
xyz?list_id=11111&list_id=2222&list_id=3333
On the server side, the code would have to use getValues(String param) -> String[] (or whatever api they have).
b) If you insist on a proprietary list format, you will have to urlencode each key and value independently, as usual, which means '[' as %5B and ']' as %5D (along with other unsafe chars). https://en.wikipedia.org/wiki/Percent-encoding
xyz?list_id=%5b11111%2c2222%2c3333%5d
The server side has to getValue(param) (typically urldecoded already) and will have to parse further your custom format (for which you could easily forget the [ ] since they are not helping).
Note: I assumed you are not asking about how to use StringBuilder.append()...lol