Skip to main content
Question

HTTPCaller - How to get a value from the response_body

  • August 4, 2021
  • 4 replies
  • 579 views

plynn
Contributor
Forum|alt.badge.img+10
  • Contributor
  • 9 replies

I am using the HTTPCaller transformer to perform a GET. How do I take the response and pull out specific attributes and their values?

 

For example, I pass in a list of 5 asset numbers to the HTTPCaller. It performs the GET to return all associated information for each of those assets. I need to pull out, from the response body, only the assetnum and status.

4 replies

virtualcitymatt
Celebrity
Forum|alt.badge.img+47
  • Celebrity
  • 2000 replies
  • August 4, 2021

It depends on the response. The response is probably JSON. In this case you need use the json tools to extract the data.

​Have a read of this article: https://community.safe.com/s/article/json-transformations

There should be some helpful tips​


plynn
Contributor
Forum|alt.badge.img+10
  • Author
  • Contributor
  • 9 replies
  • August 4, 2021

It depends on the response. The response is probably JSON. In this case you need use the json tools to extract the data.

​Have a read of this article: https://community.safe.com/s/article/json-transformations

There should be some helpful tips​

The response is actually XML.


gazza
Contributor
Forum|alt.badge.img+6
  • Contributor
  • 132 replies
  • August 4, 2021

The response is actually XML.

There are a number of ways to do this but the XMLFlattener is probably the easiest to use.


virtualcitymatt
Celebrity
Forum|alt.badge.img+47
  • Celebrity
  • 2000 replies
  • August 5, 2021

The response is actually XML.

Yep, XMLFlatterner is probably the way to go. You might need to experiment with the settings a little to get the result you want. Check out the documentation of the transformer for help