Generate Target URL dynamically based on set of Query paramters

Hi Experts,

We are working on requirement where API provider will be same with one Target URL.

Source system SAP wants to share same end point but Query parameters are different for each interface. 

Common End point for Source URL1 and Source URL2:   http://host:port/RelianceDev/rest/v1/datasources/{datasource}/execute

Source URL 1: 

https://<<host>>:<<port>>/vendor/v1/api/vendordata?companyno=64728&companyname=WSGH&siteno=2834&sitename=palnt&address=Tysons One&city=NYC&state=NYC&country=USA&datasource=WS_VENDOR_SITE_PROFILE

Where bold strings above are Query parameters like companyno, companyname, siteno etc..

Corresponding Target URL 1: [Where {datasouce} indicates value that needs to be populated from Source URL 1, for example here datasouce =WS_VENDOR_SITE_PROFILE . Similarly others]

http://<<Targethost>>:<<Targetport>>/VendorDev/rest/v1/datasources/{datasource}/execute?SSP_COUNTRY$PARAM='{companyname}'&COMPANY_NAME$PARAM='{companyname}'&COMPANY_NUMBER$PARAM='{companyno}'&SSP_NUMBER$PARAM='{siteno}'&SSP_NAME$PARAM='{sitename}'&SSP_ADDRESS$PARAM='{address}'&SSP_CITY_COUNTY$PARAM='{city}'&SSP_STATE$PARAM='{state}'&COUNTRY$PARAM='{country}' 

Source URL 2 [will have only 3 query parameters] but shares same end point.

https://<<host>>:<<port>>/vendor/v1/api/vendordata?companyno=64728&companyname=WSGH&datasource=WS_VENDOR_COMPANY

Corresponding target URL 2: [where {companyno}, {datasource} etc.. indicates corresponding values of query parameters that needs to be passed to Target URL placeholder]


http://<<Targethost>>:<<Targetport>>/VendorDev/rest/v1/datasources/{datasource}/execute?COMPANY_NAME$PARAM='{companyname}'&COMPANY_NUMBER$PARAM='{companyno}'

 

Kindly help me to acheive this requirement in APIGEE / APIM using Java script or policies.

Since I am beginner , kindly guide me step by step  approach to acheive this requirement.

Thank you!

 

Regards,

Nithin.

 

0 1 277
1 REPLY 1

Apigee proxy will pass in the query parameters it receives to the target host. So you can achieve routing of your two requests via single Apigee proxy.

You will be creating simple Apigee proxy with the following customization in HTTPTargetConnection inside TargetEndpoint definition.

<HTTPTargetConnection>
<URL>http://<<Targethost>>:<<Targetport>>/VendorDev/rest/v1/datasources/{request.queryparam.datasource}/execute</URL>
<Properties>
</Properties>
</HTTPTargetConnection>

In the above snippet replace Targethost and Targetport with actual values. At runtime Apigee will replace the flow variable "request.queryparam.datasource" with the queryparam value. For more info about flow variables refer here.

If you want more advanced logics to seperate the flows checkout this doc.
https://cloud.google.com/apigee/docs/api-platform/fundamentals/flow-configurations

Hope this info helps you.
Thanks.