Original Message:
Sent: Fri August 25, 2023 08:51 AM
From: Steven Cawn
Subject: Unable to use the substring finction in the set variable policy
I should call out that if you need to use a GatewayScript function, this is only available on the AWS Advanced plan, not the base Enterprise or free plan.
------------------------------
Steven Cawn
Sales
IBM
Original Message:
Sent: Thu August 24, 2023 02:13 PM
From: Steve Linn
Subject: Unable to use the substring finction in the set variable policy
Hi Pragnesh,
Per https://www.ibm.com/docs/en/api-connect/10.0.5.x_lts?topic=execute-set-variable, the value "Can be a literal value, or another variable." If you need to do a substring you'll need a GatewayScript policy that gets the variable from context, does the substring, and sets the new variable. Also note that request.parameters.paramName actually returns an object of two arrays. The first array is an array of strings with the location of the parameter (query, path, form) and the second array is an array of string values associated with the parameter at a particular location. In most cases where you don't have the same parameter name in multiple locations, you'll get something like
{"locations" : ["query"], "values": ["the value"]}
so if you only have one location, you can safely do a context.get('request.parameters.state').values[0] and then do your substring of that.
Best Regards,
Steve Linn
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
Original Message:
Sent: Thu August 24, 2023 08:44 AM
From: Pragnesh Gandhi
Subject: Unable to use the substring finction in the set variable policy
Hi
Hope this finds you well.
We have migrated from IBM API connect v5 to IBM API connect SaaS on AWS v10. However, in the migration, we need to compute the substring of "state" request parameter variable and pass to header so we have written following code
- set-variable:
version: 2.0.0
title: set-variable
actions:
- set: message.headers.state
value: substring($(request.parameters.state), 0,3)
type: string
We are not getting the validation errors but the desired output is not produced.
Note: We are using the plan "base tier".
Can someone help here what is the issue is it of the plan we are using or we are using wrong function.
------------------------------
Pragnesh Gandhi
------------------------------