How to apply Api key in a flow?

Not applicable

Hi I've created a simple Verify Api Key policy, and when I apply to a Pre-flow it works fine. But I would like to apply for a Flow. How can I do it?

<PreFlow name="PreFlow">
        <Request>
            <Step>
                <Name>Verify-Api-Key</Name>
            </Step>
        </Request>
        <Response>
        </Response>
    </PreFlow>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<VerifyAPIKey async="false" continueOnError="false" enabled="true" name="Verify-Api-Key">
    <DisplayName>Verify-Api-Key</DisplayName>
    <Properties/>
    <APIKey ref="request.header.x-api-key"/>
</VerifyAPIKey>

I'd like to apply here:

<Flow name="put /v1/myresource/{Id}">
            <Description>get resource by id</Description>
            <Request>
                <Step>
                    <Name>Verify-Api-Key</Name>
                </Step>
            </Request>
            <Response/>
<Condition>(proxy.pathsuffix MatchesPath "/v1/myresource/*") and (request.verb = "PUT")</Condition>
</Flow>

Thanks for your help

Solved Solved
0 5 322
1 ACCEPTED SOLUTION

@Lucio Moraes

Please refer the documentation , this has detailed explanation of using resource path.

This might help you in setting the proper condition for the flow to be started. W.r.t adding verify API key step you have coded absolutely correct.

Thanks

View solution in original post

5 REPLIES 5

Hi @Lucio Moraes

From the above code you have added the verify api key policy correctly .

However i hope you are calling the resource with the complete path and method (i.e in your case it would be https://xxxxx-test.apigee.net/apiname/v1/myresource/123 with request verb as PUT.

This would allow request to enter the condition flow you have created and ivoke verify api key policy.

Hope this helps

Cheers

Ateeb

Hi @Mohammad Ateeb Shaik

I did a slightly change and it worked. I used the documentation bellow.

Thank you

@Lucio Moraes

Please refer the documentation , this has detailed explanation of using resource path.

This might help you in setting the proper condition for the flow to be started. W.r.t adding verify API key step you have coded absolutely correct.

Thanks

Hi @Latheef

I've follow the doc and it worked. But I have one more question.

Thank you

What I did was the follow

<Flow name="get /v1/myresource/all">
<Description/>
<Request>
<Step>
<Name>Verify-Api-Key</Name>
</Step>
</Request>
<Response/>
<Condition>(proxy.pathsuffix MatchesPath "/myresource/all") and (request.verb = "GET")</Condition>
</Flow>

and I've created a new api product to access a Resource path: /myresource/all