If Using the Solution Builder: Custom Analytics Collection wizard (found under the Tools menu when on the Develop tab of an API proxy) to define more than one variable taken from a JSONPayload, the generated ExtractVariables policy will be built incorrectly for the <JSONPayload> element.
Here's an example via Screen shot.
This is the generated ExtractVariables policy code.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="true" enabled="true" name="__extract-statistics-request__"> <!-- Created by the Custom Analytics Collection tool on: Fri Feb 06 2015 17:13:32 GMT-0800 (PST) --> <DisplayName>Extract Statistics Request</DisplayName> <JSONPayload> <Variable name="_jsonPayloadAction" type="string"> <JSONPath>$.records[0].headerAction</JSONPath> </Variable> </JSONPayload> <JSONPayload> <Variable name="_jsonPayloadLocalTimestamp" type="string"> <JSONPath>$.records[0].localTimestamp</JSONPath> </Variable> </JSONPayload> </ExtractVariables>
The result of the wizard is that it created two <JSONPayload> elements. The result of this is that only the bottom Variable (_jsonPayloadLocalTimestamp) will be populated. The first one will be empty.
Fix
Until we can get this wizard issue corrected, please adjust the generated policy so that it has only one <JSONPayload> element as follows.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="true" enabled="true" name="__extract-statistics-request__"> <!-- Created by the Custom Analytics Collection tool on: Fri Feb 06 2015 17:13:32 GMT-0800 (PST) --> <DisplayName>Extract Statistics Request</DisplayName> <JSONPayload> <Variable name="_jsonPayloadAction" type="string"> <JSONPath>$.records[0].headerAction</JSONPath> </Variable> <Variable name="_jsonPayloadLocalTimestamp" type="string"> <JSONPath>$.records[0].localTimestamp</JSONPath> </Variable> </JSONPayload> </ExtractVariables>