Hi Steve...
AcctBal is an array of primitives (string, number), the proeprty name is present as [BalType, BalAmt]. Below is the code we have written in the map policy and attached is the map policy.
Map policy Code:
===============
var retValue = undefined;
if ($(BalAmt) !== null) {
var randomNo = apim.getvariable('randomNo');
var IV = apim.getvariable('IV');
var crypto = require('crypto');
var cipher = crypto.createCipheriv('aes256-cbc',Buffer.from(randomNo, 'utf8'),Buffer.from(IV, 'utf8'));
var ciph = cipher.update($(BalAmt),'utf8');
retValue = ciph.final('base64');
}
Error received:
===============
5:37:41 PM apiconnect error 70993247 request 10.9.63.211 0x85a0000a apigw (APICSIT): Map: API=accountinquiry, policy=mapFetchAccountDtlsRes : set action $item: invalid value expression and no default configured. {"set":"$item","from":"$item","value":"var retValue = undefined;\r\nif ($(BalAmt) !== null) {\r\n\t\tvar randomNo = apim.getvariable('randomNo');\r\n\t\tvar IV = apim.getvariable('IV');\r\n\t\tvar crypto = require('crypto');\r\n\t\tvar cipher = crypto.createCipheriv('aes256-cbc',Buffer.from(randomNo, 'utf8'),Buffer.from(IV, 'utf8'));\r\n\t\tvar ciph = cipher.update($(BalAmt),'utf8');\r\n\t\tretValue = ciph.final('base64');\r\n}"}
5:37:41 PM apiconnect error 70993247 request 10.9.63.211 0x8580005c apigw (APICSIT): Map: API=accountinquiry, policy=mapFetchAccountDtlsRes : set action $item: invalid valueString expression: var retValue = undefined; if (BalAmt !== null) { var randomNo = apim.getvariable('randomNo'); var IV = apim.getvariable('IV'); var crypto = require('crypto'); var cipher = crypto.createCipheriv('aes256-cbc',Buffer.from(randomNo, 'utf8'),Buffer.from(IV, 'utf8')); var ciph = cipher.update(BalAmt,'utf8'); retValue = ciph.final('base64'); }
------------------------------
Ashok Beshra
------------------------------
Original Message:
Sent: Mon June 12, 2023 09:45 AM
From: Steve Linn
Subject: Map Transform to create action for processing elements in an array
Hi Ashok,
What does your input data look like? Looking at your "Iterate over" in your screen shot, I'd anticipate seeing that property AcctBal is an array of primitives (string, number). For example "AcctBal": [1234, 5678]. That is why you see $item in the child mapping as each individual array element you are iterating over does not have a property name, so the map policy uses $item to reference unnamed properties. Is this correct or does your input schema not match your input data as far as this array is concerned? If you provided the full map policy so I can see the input schema and a sample input payload I can make a better determination of what the issue is.
Best Regards,
Steve
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
------------------------------