Hi,
I am trying to set target end point using variables from KVM. it doesn't work. why it doesn't work?
<HTTPTargetConnection> <properties> <Property name="retain.queryparams.enabled">true</Property> </properties> <URL>https://{targetApiServer}{jll.js.targetApiPath}</URL> </HTTPTargetConnection>
Please elaborate "it doesn't work"
Have you verified that the values are read from the KVM into the variables? Can you post your trace or proxy code so that we can look into the details.
You can refer to the below related posts - You need to use the AssignVariable Template option. Note, this is available in the Apigee cloud version only
https://community.apigee.com/questions/34760/how-to-set-target-url-with-a-keyvaluemap-property.html
Try setting the target.url property with AssignMessage policy in the target endpoint after fetching the KVM values.
What is the alternate for on-prem?
@vinay, may be we can construct the value in a JavaScript policy and set the target.url variable. I haven't tried it though
There are about 30+ endpoints(with diff operations) which will be too much to use js..
@vinay, even though you have 30 different endpoints you will route one request to one endpoint only right?
The thirty different endpoints will be stored in the kvm. You will be retrieving one endpoint value per request from the kvm and setting this in target.url in js policy
May be I wasn't clear..here is the question.
We basically get some path params (dynamic in request) and say we need to construct the uri based on the request received.
example we receive a value 1234 from request and we need to construct a uri and call backend
http://abcdev.com/v1/1234/callbackend1
http://abcdev.com/v1/test/1234/callbackend2
http://abcdev1.com/v1/1234/callbackend3
http://abcdev1.com/v1/test/1234/callbackend4
ask here is can we have kvm enable for the vip names & construct the url?
http://{devurl}/v1/1234/callbackend1
http://{devurl}/v1/test/1234/callbackend2
@vinay,
Question: do you want to route the request to four different backends or just one.
Assuming one
if hostname is constant, you can use a combination of target server and kvm value in the <path> element
Configure target server as devurl, read the kvm value mapped for the input parameter 1234 and set it in the path of the Target endpoint
You can structure your kvm entries based on the key you receive and the value desired. For eg: GET request 1234 mapped to 1234/backend1; POST mapped to 1234/backend2.
You can use a json payload as the value and have multiple entries in the json.
If backend hostname is different based on the parameters, you can use js policy to construct the url with the kvm value retrieved.
I will try to give you a sample tomorrow if this is what you want
@Vinay, I tried to create a sample with the info given by you. Here is the KVM definition and the proxy bundle.
I have used the proxy pathsuffix as the key in the KVM, however you can use a key that suits your needs to retrieve the target url from the KVM by extracting parameters from the URL or headers or payload.
Hope this gives you some idea on how to implement it for your usecase.
Hi @vinay , as your vip name is changing, you can go for multiple target endpoints for each vip, else its simple to use javascript policy to create dynamic uri, you can store the values in KVM and extract in the flow, even you can extract all values of the kvm using management service callout and use in subsequent policies.