Hi Experts,
We are working on API to pass some 10 query parameters values from source to target URL.
We have source URL something like below As you can see there are around 10 query parameters coming from Source system in URL pasted below.
https://<host>/org/v1/api/compdata/vendor_profile?companyno=06598&companyname=&siteno=&sitename=&address=&city=&state=&postal=&country=&pagesize=. I am using place holder and java script to pass values from query parameters passed from source to target URL.Target URL looks something like below.
http://<host>:<port>/OrgDev/rest/v1/datasources/VENDOR_PROFILE/execute?COUNTRY$PARAM='{country}'&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}'&SSP_POSTAL_CODE$PARAM='{postal}'&pagesize='{pagesize}:
Javascript used as below mentioned with getVariable and request.queryparam.{queryparam}
I pasted Javascript code for only a few parameters since same 3 lines code applies for others also.
var country = context.getVariable('request.queryparam.country');
context.setVariable("target.copy.pathsuffix", true);
context.setVariable('country', country);
var companyname = context.getVariable('request.queryparam.companyname');
context.setVariable("target.copy.pathsuffix", true);
context.setVariable('companyname', companyname);
var companyno = context.getVariable('request.queryparam.companyno');
context.setVariable("target.copy.pathsuffix", true);
context.setVariable('companyno', companyno);
.................................................... same 3 lines code for all query parameters.
My configuration works completely fine when there are only 5 or 6 query parameters but does not work there are more query parameters from source like in this case where there are 10 query parameters. Even API is not getting deployed when I give above target URL in bold as per below screenshot. Looks like there is limitation of 256 characters to be used in Target URL when I try to deploy the API itself.
I get below error when I try to deploy the API like unable to update API and when I remove some query parameters to adjust the characters count to 256 or less then API is getting deployed successfully.
The above configuration works fine when there are only less query parameters.
I also used Assign Message policy in ProxyEndpoint - postflow to acheive this requirement but even that is not working. Please find below policy used.
Assign message policy looks like below in my case since there are multiple query parameters.
<AssignMessage async="false" continueOnError="false" enabled="true"> <Add>
<QueryParams>
<QueryParam name="SSP_COUNTRY$PARAM">{request.queryparam.country}</QueryParam>
<QueryParam name="COMPANY_NAME$PARAM">{request.queryparam.companyname}</QueryParam>
<QueryParam name="COMPANY_NUMBER$PARAM">{request.queryparam.companyno}</QueryParam>
<QueryParam name="SSP_NUMBER$PARAM">{request.queryparam.siteno}</QueryParam>
<QueryParam name="SSP_NAME$PARAM">{request.queryparam.sitename}</QueryParam>
<QueryParam name="SSP_ADDRESS$PARAM">{request.queryparam.address}</QueryParam>
<QueryParam name="SSP_CITY_COUNTY$PARAM">{request.queryparam.city}</QueryParam>
<QueryParam name="SSP_STATE$PARAM">{request.queryparam.state}</QueryParam>
<QueryParam name="SSP_POSTAL_CODE$PARAM">{request.queryparam.postal}</QueryParam>
<QueryParam name="pagesize">{request.queryparam.pagesize}</QueryParam>
</QueryParams>
</Add>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
<AssignTo createNew="false" type="request">request</AssignTo>
</AssignMessage>
It is throwing error in postman as shown below.
I am getting below error on debub mode, kindly help to resolve this.
I am getting below errors on Debug mode.
Marked step on above debug mode is having below one of the parameters.
Could you please guide me if we need to use Javascript to buid query paramters on Target URL or it could be possible by even Assign Message policy also. Do we need to setback URI using Javascript to acheive this requirement , Kindly guide to acheive this.
Thank you!
Regards!