Handling servicecallout response

Not applicable

In my code, I have a ServiceCallout to Google geocode API. Once the ServiceCallout returns, I want to check for errors in the geocode API call.

The problem with Google Geocode API is it returns an HTTP 200 in all case. However, the error is returned like this:

{
    "error_message": "You have exceeded your daily request quota for this API.",
    "results": [],
    "status": "OVER_QUERY_LIMIT"
}

So, in order for me to check the error, I need to check for the "status" field in the calloutResponse object. ("Status" != "OK")

What is the smartest way to set the condition statement for a RaiseFault policy? The following does NOT work, as calloutResponse.content is a string.

                <Step>
                    <Name>RF-SC-Failure</Name>
                    <Condition>(calloutResponse.content.status != "OK")</Condition>
                </Step>

Please help.

Regards,

Ritwik

Solved Solved
0 1 211
1 ACCEPTED SOLUTION

sidd-harth
Participant V

Hi @ritwik_chatterjee, generally we use an Extract Variable policy after SC, extract the status & then use a RF with status condition

View solution in original post

1 REPLY 1

sidd-harth
Participant V

Hi @ritwik_chatterjee, generally we use an Extract Variable policy after SC, extract the status & then use a RF with status condition