Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

In Extract variable policy I am unable to extract json array parameters from array

Not applicable

Below you can find my extract variable policy

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-Variables-1"> <!--<Source>response</Source>--> <JSONPayload> <Variable name="programs"> <JSONPath>$.programs[:].programBrandCode</JSONPath> <!--<JSONPath>$.programs</JSONPath>--> </Variable> </JSONPayload> <VariablePrefix>programs</VariablePrefix> </ExtractVariables>

And my JSON array

{ "success": "true", "programs": [ { "programBrandCode": "TM", "programAvg": "0.1094" }, { "programBrandCode": "BE", "programAvg": "0.0000" }, { "programBrandCode": "21D", "programAvg": "0.0000" } ] }

using programBrandCode I need to hit one more API get the response and it should be post to the user

Added Javascript file to my API but I unable to run for loop below you can find the code for it

first I store the response into the programs variable, after that in for loop I add the condition of programs.length to run the loop, but here it gave me invalid programs length

var programs = context.proxyRequest;

for(i = 0; i<programs.length; i++){

Kindly tell me how can I extract attributes from JSON array.

Could I replace extract variable policy with javascript callout policy?

0 3 2,352
3 REPLIES 3