informix-community

Open full view…

REST Java programming - handling curly braces!

shesh
Tue, 25 Sep 2018 07:44:23 GMT

When you are writing Java programs to makes REST calls to Informix server, you need to be aware about nuisance of curly braces! Java programs doesn't like curly braces ({ }) to be part of the string/input. Instead it needs to be encoded to respective hexadecimal values i.e. 7B ({) and 7D (}). For example: You want to select/update/delete a table with particular condition (where clause) then following needs to be written using Java. String url_val = http://<IP>:<port>/<dbname>/<table name>?query=%7B<column name>:<value>%7D"; i.e. "http://1.2.3.4:27017/mydb/people?query=%7Bemp_id:1%7D"; instead of: String url_val = http://<IP>:<port>/<dbname>/<table name>?query={<column name>:<value>}"; i.e. "http://1.2.3.4:27017/mydb/people?query={emp_id:1}"; If you don't use hexadecimal values then not so understandable error (below) will be reported, making it wonder what's going on!! [unexpected end of stream on Connection{<IP>:27017, proxy=DIRECT hostAddress=<IP> cipherSu ite=none protocol=http/1.1} (recycle count=0)] By the way, with curly braces the same REST link/query works on Postman, hence further creating the confusion!!