cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
IAQG
Advocate I
Advocate I

How to retrieve a specific field in a web service response?

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.

1 ACCEPTED SOLUTION

Accepted Solutions
IAQG
Advocate I
Advocate I

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.

View solution in original post

2 REPLIES 2
PBrt
Advocate I
Advocate I

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

IAQG
Advocate I
Advocate I

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.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,094)