Configure the get.stores Case:
This operation will call out to the Google Geocode API to obtain location information about the provided zip code, then utilize a simple gatewayscript to modify the response and provide a formatted Google Maps link.
-
Add an invoke policy to the
get.storescase.
-
Edit the new invoke action with the following properties:
Title:
invoke_google_geolocateURL:
https://maps.googleapis.com/maps/api/geocode/json?&address={zip}Stop on error:
uncheckedResponse object variable (scroll to the bottom):
google_geocode_response


-
Click the
Xto close the invoke editor. -
Add a
gatewayscriptpolicy with the following properties:Title:
gws_format_maps_linkCopy the following GatewayScript snippet and paste it into the text area:
// Save the Google Geocode response body to variable var mapsApiRsp = apim.getvariable('google_geocode_response.body'); // Get location attributes from geocode response body var location = mapsApiRsp.results[0].geometry.location; // Set up the response data object, concat the latitude and longitude var rspObj = { "google_maps_link": "https://www.google.com/maps?q=" + location.lat + "," + location.lng }; // Save the output apim.setvariable('message.body', rspObj);
Note:
Take a quick look at line 5. Notice how our gateway script file is reading the body portion of thegoogle_geocode_responsevariable which was assigned to the output of theinvokeaction. -
Click the
Xto close the gatewayscript editor. -
Your assembly for the
logisticsAPI will now include two separate operation policies:
-
Save your changes.

-
Click on the
<- All APIslink to return to the draft APIs list.
Conclusion
Congratulations! You have successfully configured two new API’s with advanced assemblies. In the next lab, you will bundle the API’s into a Product and publish it to the consumer portal.
Proceed to Lab 6 - Working with API Products.