Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Extract variables from json if one of the element is not present

I have similar policy in my proxy :

<ExtractVariablesname="Extract-valid-until-date" continueOnError="false" >
<DisplayName>Extract token chorus</DisplayName>
<Source>chorusresponse</Source>
<JSONPayload>
<Variablename="valid_until">
	<JSONPath>$.valid_until</JSONPath></Variable>
<Variablename="response_error">
	<JSONPath>$.error</JSONPath></Variable>
</JSONPayload>
</ExtractVariables>

If valid_until variable is not present in request, it throws an error :

{"fault":"{\"detail\":{\"errorcode\":\"steps.extractvariables.InvalidJSONPath\"},\"faultstring\":\"Invalid JSON path $.valid_until in policy Extract-valid-until-date.\"}"}

if i changed continueOnError="true", then it moves ahead but it doesn't capture second element value as well because the error has come on 1st element and policy was terminated there itself. I can use JS as well for my purpose. But is there any way to handle in extract variable policy ?

Thanks

0 5 780
5 REPLIES 5