I need to send a GET request. One of the parameters has URL query characters in it (e.g., ?, &, and =). How do I URI-encode that in KRL before sending the request?
Here's the pseudocoded idea:
params = "key=value&key=value";
encoded_params = params.ur开发者_JAVA百科lencode();
request = datasource:service("?data=#{encoded_params}");
You can either pass a string or a struct when you call a datasource. When you use a hash, the hash values are URL encoded automagically by the platform.
Your code above would be written like so:
rparams = {
  "key1": "value1",
  "key2": "value2"
};
request = datasource:service(rparams);
TaDa! Magic.
Note that I used string literals in the hash declaration, but those can be any expressions, and the values will be passed as the arguments in the datasource request.
See also http://docs.kynetx.com/docs/URI
escaped = uri:escape("a b c d"); // "a%20b%20c%20d"
original = uri:unescape(escaped); // "a b c d"
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论