How to pass dynamic values to Apigee with key?

635 Views Asked by At

I have a rest application that pulls data from database based on the user choice of City or County via UI.

The city, and county are dynamically passed in as the user is able to choose all 50 states.

The endpoints are like this:

http://localhost:8080/my-api/state/FL/City
http://localhost:8080/my-api/state/FL/County
http://localhost:8080/my-api/state/CA/City
http://localhost:8080/my-api/state/AK/County
etc...etc....

Now I want to secure these endpoints using Apigee along with a key. I have created the proxy and product and able to get json from application with my new Apigee URL:

https://company.api-nonprod.com/my-first-api/state/TX/City?apikey=ldekQ5VqlXFQq7YusetSeqbeidxdo5

So far so good. :)

Now I need to add this EndPoint to the front end configuration file.
My local endpoint worked fine.

 http://localhost:8080/my-api/state

How do I add this new Apigee Endpoint and key?

This doesn't work as it keeps appending the parameters to the end of url instead of before the apikey.

https://company.api-nonprod.com/my-first-api/state?apikey=ldekQ5VqlXFQq7YusetSeqbeidxdo5

error url

https://company.api-nonprod.com/my-first-api/state?apikey=ldekQ5VqlXFQq7YusetSeqbeidxdo5/TX/City

After going over the Apigee documentation I made my way to the Develop tab in which I can specify how the APIKey can be referenced.

<VerifyAPIKey name="APIKeyVerifier">
    <APIKey ref="request.formparam.x-apikey"/>
</VerifyAPIKey>

<VerifyAPIKey name="APIKeyVerifier">
    <APIKey ref="request.header.x-apikey"/>
</VerifyAPIKey>

<VerifyAPIKey name="APIKeyVerifier">
    <APIKey ref="request.queryparam.x-apikey"/>
</VerifyAPIKey>

Now I'm stuck in AssignMessage message documentation.

How do I pass dynamic values to Apigee with key?

1

There are 1 best solutions below

0
On

You have to handle constructing URL in your application.

Try to hit from postman.. have your proxy url and your requestMapping appened with your proxy url.

it should work, or it would have worked by this time ;) , since two months gone :P