how to access response code variable in case of failure?

Not applicable

I have defined DfaultFaultRule and inside that my logging javascrict policy is called. Now In case of failure i am not able to access response flow variables. I want to access status code for logging inside my javascript policy. How to do that ?

Solved Solved
0 8 909
1 ACCEPTED SOLUTION

@utsav kansara ,

You can use flow variable message to get response details, To access response code you need to use below variable.

message.status.code

Variables details are documented here, Check topic under "Message Variables". Message variables are contextual: they refer to different message types (request, response, or error) depending on the point within the API Proxy Flow in which they are called.

See attached proxy which prints same in Default fault rule, Javascript policy.

2341-screen-shot-2016-04-06-at-83354-am.png

failproxy-rev1-2016-04-06.zip

View solution in original post

8 REPLIES 8

@utsav kansara ,

You can use flow variable message to get response details, To access response code you need to use below variable.

message.status.code

Variables details are documented here, Check topic under "Message Variables". Message variables are contextual: they refer to different message types (request, response, or error) depending on the point within the API Proxy Flow in which they are called.

See attached proxy which prints same in Default fault rule, Javascript policy.

2341-screen-shot-2016-04-06-at-83354-am.png

failproxy-rev1-2016-04-06.zip

Thanks a lot @Anil Sagar ! This worked for me. 🙂

@utsav kansara

Anytime 🙂 Glad issue is resolved.

one more thing @Anil Sagar! Can I also get error description ? can I use "message.transport.message" for getting exact error description ? Thanks in advance.

I got it by "message.content" !!! 🙂

@utsav kansara , Awesome, Use trace tool to debug & explore flow variables.

@utsav kansara , Have you tried anything ? Do you see any error ?

Thanks - that pointer to "message" is valuable also for other cases!