How to log status.code in a no-target API Proxy ?

We are trying to log the status.code variable in our API Proxies. We noticed that in API Proxies that uses a no-target route, the status.code field is not populated even though the response to the http client includes it.

Also when we trace the request and look at the 'AX' phase at the end of the request we see that message.status.code shows 200. But, when we try to access this field through a javascript policy in the response flow, we see it is not populated.

Is there a way to get the status.code from javascript when the route is no-target ?

0 1 302
1 REPLY 1

In a no-target API Proxy, the response status will be set only after all the policies in the response flow are executed.

In this API Proxy, the response variables such as status.code were being retrieved in a JS policy in the response flow even before they were set. Hence the values were not populated.

As the requirement was to log the variables, the right thing to do is to use MessageLogging Policy in the Post Client Flow. In the Post Client Flow, the response variables will be set and they could be logged.


More information about the Message Logging policy here