Hi Ravi,
You can convert the json object into a string, then do string splitting on the object by using the name of the duplicate object as an input. If the resultant array contains more than two elements then throw an error else continue the parsing. PFB the ESQL code to implement this functionality.
CALL Split(CAST(ASBITSTREAM(InputRoot.HTTPInputHeader CCSID 1208) AS CHARACTER CCSID 1208), OutputLocalEnvironment, 'duplicateKey');
CREATE PROCEDURE Split (IN S CHARACTER, IN Env REFERENCE, IN Delim CHARACTER)
BEGIN
DECLARE P INTEGER;
DECLARE Idx INTEGER 1;
SET Env.Split = NULL;
REPEAT
SET P = POSITION(Delim IN S);
IF P = 0 THEN
SET Env.Split.Array[Idx] = S;
ELSE
SET Env.Split.Array[Idx] = LEFT(S, P - 1);
SET S = SUBSTRING(S FROM P + LENGTH(Delim));
SET Idx = Idx + 1;
END IF;
UNTIL P = 0
END REPEAT;
END;
------------------------------
Ali Mazhar
------------------------------
Original Message:
Sent: Mon September 05, 2022 03:14 AM
From: ravikumar kunibilli
Subject: Parse policy- Duplicate Key in JSON Request
Hello All,
Can anyone assist me on above posted scenario.
My API flow will be like below, I can't remove Parse as we configured Validate policy for the validation. Parse policy is removing the duplicate keys and processing the request hence we are getting success response instead of error response from the backend.
How can we handle duplicate keys in API Connect to pass the request to the backend as it is.
Parse--Validate--Invoke
------------------------------
Ravikumar Kunibilli
ravikumarkunibilli@gmail.com
------------------------------