How can I validate an input to APIGee endpoint and raise a fault if input is not provided or if it is not in a valid format?
For eg: I am expecting a value to be passed in querystring. If its not supplied, I should return a error response instead of letting it pass through back-end service and fail there.
Thanks, Deepak
To accomplish this, add a Condition to the RaiseFault Policy.
For example:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProxyEndpoint name="default">
<Description/>
<Flows/>
<PreFlow name="PreFlow">
<Request>
<Step>
<FaultRules/>
<Name>RaiseFault-1</Name>
<Condition>request.queryparam.myParam == null</Condition>
</Step>
</Request>
<Response/>
</PreFlow>
<HTTPProxyConnection>
<BasePath>/myBasePath</BasePath>
<VirtualHost>default</VirtualHost>
<VirtualHost>secure</VirtualHost>
</HTTPProxyConnection>
<RouteRule name="default">
<TargetEndpoint>default</TargetEndpoint>
</RouteRule>
<PostFlow name="PostFlow">
<Request/>
<Response/>
</PostFlow>
</ProxyEndpoint>