Hi All,
I want to use the IsValid and Result variables from the Response content(refer the below image) to raise faults in the Apigee, can someone help me out?
Solved! Go to Solution.
@gopal
Extract the response variables IsValid and Result using Extract Variables or JavaScript policy. Below is using Extract Variables policy.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-Variables-1"> <DisplayName>Extract Variables-1</DisplayName> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <JSONPayload> <Variable name="isValid"> <JSONPath>$.IsValid</JSONPath> </Variable> <Variable name="result"> <JSONPath>$.Result</JSONPath> </Variable> </JSONPayload> <Source clearPayload="false">response</Source> </ExtractVariables>
Use those variables in step condition to raise the fault when condition is matched.
<Step> <Name>raise-fault</Name> <Condition>(isValid == false AND result == false)</Condition> </Step>
Hope this hepls.
@gopal
Extract the response variables IsValid and Result using Extract Variables or JavaScript policy. Below is using Extract Variables policy.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-Variables-1"> <DisplayName>Extract Variables-1</DisplayName> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <JSONPayload> <Variable name="isValid"> <JSONPath>$.IsValid</JSONPath> </Variable> <Variable name="result"> <JSONPath>$.Result</JSONPath> </Variable> </JSONPayload> <Source clearPayload="false">response</Source> </ExtractVariables>
Use those variables in step condition to raise the fault when condition is matched.
<Step> <Name>raise-fault</Name> <Condition>(isValid == false AND result == false)</Condition> </Step>
Hope this hepls.
thanks @kirankoona 🙂 it worked fine and I have one similar doubt , I want to use the IsValid and Result variables from the service callout respone and use then in the raise faults - please refer the screenshot .
ServiceCallout response is stored in variable mentioned in ServiceCallout response element. In below code, ServiceCallout response is stored in 'mockresponse' variable. Use that variable in extract variable policy as source.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ServiceCallout async="false" continueOnError="false" enabled="true" name="SC-GetMockResponse"> <DisplayName>SC-GetMockResponse</DisplayName> <Request clearPayload="false" variable="myrequest"> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> </Request> <Response>mockresponse</Response> <HTTPTargetConnection> <Properties/> <URL>http://mocktarget.apigee.net</URL> </HTTPTargetConnection> <Timeout>30000</Timeout> </ServiceCallout> <br>
Refer to docs for more understanding on service callouts : https://docs.apigee.com/api-services/reference/service-callout-policy
Hope this helps.
@kirankoona thanks for your input and everything is working as expected!
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |