Query with '&' in the query value
Hello,
Im using a business rule and http.get to query a database (sql server). In some cases the query value passed in the http.get has an ampersand. This is probably interpreted as a name value pair separator, and truncates the string used for the actual query. If I use encodeURIComponent the ampersand is encoded, but the encoded value is used for the query, which of course does not match any values. Is there a method or best practice to allow the use of unsafe or reserved characters for query values?
-
If I'm understanding correctly you can just put it in quotes so for example
eval (
'x='
+ http.get(
'http://localhost:8082/database/BIRT/ordersByCustomer?cnum='
+ sc.value + '&id=' + ID.value));
0 -
Hello Mike,
Thanks for the reply. Lets look at it like this:
eval (
'x='
+ http.get(
'http://localhost:8082/database/BIRT/ordersByCustomerName?name='
+ name.value));
In this example case name.value= 'John & Sons'
If I capture the query given to sql, its just 'John'. If I encode the query value in the business rule, then the encoded string is given to the sql query. Although this can work, you have to decode, the value before running the query on the sql side. And unless Ive missed it ms sql does not have a decode function, meaning either a targeted replacement or building something in sql to do decoding.
0 -
Hi Jeff,
Could you try this:
eval (
'x='
+ http.get(
'http://localhost:8082/database/BIRT/ordersByCustomerName?name="'
+ name.value + '"'));
This will surround the value you are trying to pass with quotes. Maybe that will help?
-Prajakta
0 -
Hi.
Will GET with a json payload work with the database connector?
The docs seem to show that you can pass payload that way. But so far the db connector hasnt responded with results, just ok. The payload method with the above case, "&" works when used for PUT.
0 -
Please see this documentation about HTTP methods in business rules. The http.get method does not accept JSON payload. You can only send headers with http.get.
Thanks,
Prajakta
0
Please sign in to leave a comment.
Comments
5 comments