I have created a proxy that has a target url to a third party. I purchased a user code, that is required at the end of the path, not as a query parameter.
Example: https://this.url.com/{{input}}/{{my user code}}
I want to provide this to my customers, but I want to hide my user code. I had thought I could append it to the request like we do with query parameters, but I cannot find an Add Path, or Append Path options in the Assign Message Policy.
For example, I want my customer to see in the swagger spec the only what they need to input. I want them to send to my proxy https://this.url.com/123456
then in the proxy I wish to append the user code like this: https://this.url.com/123456/abcdefg What is the best way to accomplish this?
It can be done via Assign Message Policy or a simple Javascript policy. So how are you going to get the my_user_code value?
Sample JS code, it should change based on your proxy design,
I assume the values are extracted from extract variable policy,
var input = context.getVariable("urirequest.input"); var user_code= context.getVariable("urirequest.user_code"); if(user_code !== null ){ var targeturl = context.getVariable("target.url"); context.setVariable("target.url", targeturl+"/"+ input +"/"+ user_code); }
Thank you! The customer provided the product code in the path, I have a fixed account code that I appended. This allows me to abstract away my code from the customers.
This is the JavaScript Policy added to the Target Endpoint Preflow:
var targeturl = context.getVariable("target.url");
var path = context.getVariable("proxy.pathsuffix");
context.setVariable("target.url", targeturl+"/"+path+"/my code");
It worked great! Thanks for your help.
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |