I am using Property sets in Apigee Hybrid to store key value pairs. When I try to read the keys it gives null value or returns error.
File Name - myprops.properties# myProps.properties file foo=bar
Using ExtractVariables policy -
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables name="ExtractVariables-1"> <DisplayName>ExtractVariables-1</DisplayName> <Source>request</Source> <Variable name="myVar"> <Pattern>{propertyset.myprops.properties.foo}</Pattern> </Variable> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> </ExtractVariables>
This variable returns empty value.
Using AssignMessage Policy - This returns error response as Key is invalid.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AssignMessage async="false" continueOnError="false" enabled="true" name="Assign-Message-1"> <DisplayName>Assign Message-1</DisplayName> <Properties/> <Set> <Payload content-type="application/json">{ "message": "{myVar}", "value": "{propertyset.myprops.properties.foo}" } </Payload> </Set> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <AssignTo createNew="false" transport="http" type="response"/> </AssignMessage>
Using Javascript - This also returns error as invalid Key
var property = context.getVariable('propertyset.myprops.properties.foo'); print("property is -"+ property);
Is there anything I am missing here.
Solved! Go to Solution.
I'm happy to report that the Property Set issue at the proxy scope is now fixed.
Attached is an example proxy showing usage for Assign Message, Extract Variables and JavaScript policies.
Thanks for the recommendation, however I think I will stick to KVM for the following reasons:
Quick question: Can we put the error mapping data in CSV format as the value of a KVM key? A CSV is probably a more easier and non-technical way to hold the error mapping making it easier to update by a wider audience using an Excel Spreadsheet
@SidDas wrote:
Can we put the error mapping data in CSV format as the value of a KVM key?
Yes but the "value" part of the KMV entry is a string, so it needs to be valid JSON in the curl request (no newlines, escaped quotes, etc.).