Layer7 API Management

  • 1.  Combine 2 external API results into a single response

    Posted Jul 03, 2015 07:02 AM

    I'm currently on a CA API Gateway training course, and am having a bit of a play. I've got a policy written that does some parameter sanitisation and then make a route out to the Google Distance API... and it works! Hoorah!

     

    Capture.JPG

     

    Now I want to add some further complexity, and I just don't think I have a clear enough understanding of the flow or some of the available assertions to be able to achieve what's in my head. I'd like to make a call out to the graphs.facebook.com API (have a key which I can burn in) to grab a friends "location" and my current "location", and then take the result of those location requests and use it in a call to the Google Distance API and deliver back some JSON that represents the friend, the two locations and the distance between.

     

    In my head, CA API Gateway should be able to do this type of funkery... but I don't understand how... Is there anyone out there that has an example policy of this type, or a fragment that may help me?

     

    Thanks in advance

     

    Jonathan



  • 2.  Re: Combine 2 external API results into a single response
    Best Answer

    Posted Jul 03, 2015 08:58 AM

    Ah... just seen the "Response Destination" field in the "Route to" assertion. ${httpResponse.content} gets me what I need. I can then XPATH or Regex to my hearts content!