Monday, June 16, 2014

stdout in Javascript Callout

Writing to console in Javascript callout is useful in some scenarios of debugging.  The print function can be used for writing to stdout.

print('Hello World From Javascript Callout');

would output the message to stdout.

stdout can be seen in trace when you click on the Javascript policy that logged to console.

Monday, June 9, 2014

Flow variables in URL of HTTPTargetConnection

HTTPTargetConnection with URL can be  used in two places as of now - service callout and target endpoint. Following are the configuration differences in both usages.

Service Callout

Target Endpoint


  • Protocol must be static in both cases it cannot be part of a flow variable used. The validation of requirement is done during deployment time.
  • Host ( in above example) must be static in case of target endpoint. This cannot be part of flow variable; making host part of the flow variable causes failure with error code 500 even though the validation during deployment succeeds.

Monday, June 2, 2014

Handling 404 backend response

In REST API interactions its common to obtain and handle 404 response. The behaviour is used to support create or update scenario for a resources. Check if the resource exists, if it does update it using PUT otherwise create it using POST verb.

404 response from backend is treated as an error in Apigee and such a response results in execution of the fault flow instead of the response flow. The method of dealing with such a scenario is to use the property of target endpoint properties. Following is an example configuration of target end point to deal with 404 as a success response.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TargetEndpoint name="billing">
            <Server name="BillingTarget">
            <Property name="">1XX,2XX,3XX,404</Property>

The success codes property above ensures that default behaviour is retained in addition to treating 404 as a success code. This configuration will ensure response flow of the proxy will be executed in case of 404 response too. Appropriate action can be take in the response flow by checking the status code value.