Hi all,
I'm just starting to use the Invoke Web Service step, and I was wondering if there's a way to retrieve a specific field from a response? For example, if I send a GET call that pulls back a customer's information with fields like "First Name", "Last Name", and "Address", how do I pull just the first name from the response? I know I could probably write a substring that gets specific characters, but that seems a bit messy and unreliable. In other programming spaces it would be something like Response.Data("First Name") or something of the sort.
Thanks for the help.
EDIT: I should mention that this is a REST call using JSON.
Solved! Go to Solution.
Thanks for responding. It is a REST call with a JSON response, I should have mentioned that. I did not know about the JSON to object step, so that helped get me to where I needed to be. Thanks.
For the example, though, I did try your method of %response%[0], and that gave me a concatenation instead of a response, and putting the [0] inside the symbols didn't work either. For me the successful format was %response.first_name%.
Thanks for the help, though, you definitely put me on the right path.
Hi,
I guess it depends on what webservice you are using. Generally, REST webservices get you a JSon response.
If so you can use "convert Json to custom object" function that will essentially create a list object that you can then parse easily (exemple %response%[0] to get first element).
If your response is a XML file there are also a lot of premade option to parse XML files in PAD.
However you should keep in mind that REST webservices won't always get you an answear with the same structure, for exemple "first name" might not be in the response from the server. So when you parse your custom object you may have errors if you try to get something that doesn't exist.
Best regards
Thanks for responding. It is a REST call with a JSON response, I should have mentioned that. I did not know about the JSON to object step, so that helped get me to where I needed to be. Thanks.
For the example, though, I did try your method of %response%[0], and that gave me a concatenation instead of a response, and putting the [0] inside the symbols didn't work either. For me the successful format was %response.first_name%.
Thanks for the help, though, you definitely put me on the right path.