Getting the response body of an HTTP GET request is as easy as:
Set my_string = URL[http://my-server.local/]
Now, if the response body is formatted as a query string: key1=value1&key2=value2, you will need to further process your results.
You can feel free to search the web for "java query string" to see if there's code out there you like, otherwise, here's one way to do it in UCCX.
/* This Set step makes the HTTP GET request to the web server and stores the response body in the String */
Set my_string = URL[http://my-server.local/]
/* This Do step takes any size query parameter and turns it into a HashMap */
/* E.g., From this: key1=value1&key2=value2; to this: map[key1] = value1, map[key2] = value2 */
Do {
String[] pairs = my_string.split("&");
int i = 0;
int j = pairs.length;
for (; i < j; i++) {
my_map.put(pairs[i].split("=")[0], pairs[i].split("=")[1]);
}
}
/* This If step checks the existance of a specific key, and if it exists, we get the value for use in our script */
If (my_map.containsKey("key1"))
True
/* The specified key is in the map, set account_number to its value */
Set account_number = (String) my_map.get("key1");
False
/* The specified key is not in the map */
I hope that makes sense and helps you. Ask questions if you need more help. Good luck.
Anthony Holloway
Please use the star ratings to help drive great content to the top of searches.