What is the best way to avoid duplication of third party URLs for every API?
We can use the power of dynamic path variables with environment variables in vConnect’s API management.
For eg. let say your third party API url’s are
https://my-custom-domain.com/users/create
https://my-custom-domain.com/users/read
https://my-custom-domain.com/users/update
https://my-custom-domain.com/users/delete
As you can see to configure above URL’s in API management, you will need to create environment variables for each of them.
This will lead to duplication of domain and will create an issue at the time of migration or configuring another environment.
We can avoid this by creating path variables:
for e.g. in above use case,
Create following environment variables with name
APP_CUSTOM_DOMAIN
having value my-custom-domain.com
APP_CUSTOM_REST_API
having value http://{DOMAIN}/{ENTITY}/{ACTION}
What you have actually done is created a path variable url.
Now when you want to create an API, you can select this APP_CUSTOM_REST_API
as URL and then select Is the URL have dynamic path variables?
When you select this, a new tab will appear End Point Path Param Details
Go to this tab and enter
Parameter | Name | Source of Value | Value |
---|---|---|---|
Path Param 1 | DOMAIN | ENVIRONMENT | APP_CUSTOM_DOMAIN |
Path Param 2 | ENTITY | CONSTANT | users |
Path Param 3 | ACTION | CONSTANT | read |
Example screenshot
This way you have made your API completely dynamic and at the time of migration you will only need to change domain in one environment variable.