Hi, I want to do a condition match in my conditional flow to not execute a step /policy if the serviceCallout.response contains (anything preceding)403(anything following) in the response from backend server. Since payload from server is JSON based it can contain characters like "{, comma, : " example → {“error” : 403, “key”: value, “Key2” :value2 etc. }
so something like below would be incorrect but I need correct expression.
So this is full expresison in the flow (response.status.code != “403”) or (serviceCallout.response JavaRegex '^{.“error”:403.$ ) AssignMessage.CreateResponse . I am still getting error not sure what is causing this.
Service Callout policy throws an error if it receives from the target service HTTP codes 4XX or 5XX. You might want to set the success codes to HTTPTargetConnection as mentioned here. . Once you have set the success.codes, your condition will be executed. Please note that service callout uses its own response object, so your condition of response.status.code != “403” might not work. You can use servicecallout.{policy-name}.failed or {policy_response_name}.status.code and the expression as mentioned by Miren.
Thanks that’s good to know but it seems currently backend service is sending http 200 for error 403. I just placed that condition as a safeguard. Anyway the problem here is error during deployment, way before user sends request. It seems the javaregex expression is n’t recognized by Apigee during deployment .
How ever I am not sure what error you are getting. The other option I can think is to get the response, extract it using the Extract Variable policy and then raise a Fault if the extracted variable has an error.
If you can paste the exact error response payload, I might be able to help you with the policies.