How to define constants per url in a api product

Not applicable

1) First Endpoint
path: /summary/products
MultiplicationFactor 4 (constant)


2) Second Endpoint
path: /summary/products
MultiplicationFactor 10 (constant)

Is it possible to create all the above endpoints along with constant defined in a single API product. Also how can we retrieve the defined constant in api proxy.

0 4 338
4 REPLIES 4

Hi @jeevan

How are these two endpoints different if they use the same path? Do they have different VirtualHosts?

You can add MultiplicationFactor as a Custom Attribute on the Product, Developer or Developer App. Be careful if you are adding it to a Product, as a Developer App can have multiple products, so you may see inconsistent results.

Thanks, Sean

Not applicable

Both your urls look the same. Are you intending to use a constant in your proxy so that it can be replaced by its value at run-time?

If yes, i think you can use a Key Value Map to store the constant as your key and the endpoint as value.

You could also create custom variables on your api product and access the same using

apiproduct.<custom-variable> in your policy.

Not applicable

Sorry folks,

the first and second endpoint should be different.

1)/summary/products

2)/universal/products.

Thanks,

Jeevan

No problem - You can add both paths to your API Product.