ReadPropertySet policy

The ReadPropertySet policy reads property sets and populates flow variable with the results.

This policy is aStandard policy and can be deployed to any environment type. For information on policy types and availability with each environment type, seePolicy types.

<ReadPropertySet> element

Defines a ReadPropertySet policy.

Default ValueSeeDefault Policy tab, below
Required?Required
TypeComplex object
Parent Element N/A
Child Elements<Read>

The<ReadPropertySet> element uses the following syntax:

Syntax

The<ReadPropertySet> element uses the following syntax:

<ReadPropertySetname="read-property-set"><Read><Nameref="set-ref">property-set-name</Name><Keyref="key-ref">key-name</Key><AssignTo>var1</AssignTo><DefaultValue>default-value</DefaultValue></Read>...<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables></ReadPropertySet>

Default Policy

The following example shows the default settings when you add a ReadPropertySet policy to your flow in the Apigee UI:

<ReadPropertySetname="read-property-set"><Read><Nameref="set-ref">property-set-name</Name><Keyref="key-ref">key-name</Key><AssignTo>var1</AssignTo><DefaultValue>default-value</DefaultValue></Read><IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables></ReadPropertySet>

When you insert a new ReadPropertySet policy in the Apigee UI, the template contains stubs for all possible operations. See below for information on required elements.

This element has the following attributes that are common to all policies:

AttributeDefaultRequired?Description
nameN/ARequired

The internal name of the policy. The value of thename attribute can contain letters, numbers, spaces, hyphens, underscores, and periods. This value cannot exceed 255 characters.

Optionally, use the<DisplayName> element to label the policy in the management UI proxy editor with a different, natural-language name.

continueOnErrorfalseOptionalSet tofalse to return an error when a policy fails. This is expected behavior for most policies. Set totrue to have flow execution continue even after a policy fails. See also:
enabledtrueOptionalSet totrue to enforce the policy. Set tofalse toturn off the policy. The policy will not be enforced even if it remains attached to a flow.
async  falseDeprecatedThis attribute is deprecated.

The following table provides a high level description of the child elements of<ReadPropertySet>:

Child ElementRequired?Description
<Read>RequiredReads and resolves a property set variable and sets it to a specified flow variable.

<IgnoreUnresolvedVariables>OptionalDetermines whether processing stops when a property set is unresolved.

Example

This section provides an example using<ReadPropertySet>.

Example

This example uses<ReadPropertySet> to getpropertyset.environment.name.request.headers.api-version and assign it totarget_url. If the property set value isn't obtained,https://httpbin.org/get is used instead.

<ReadPropertySet name="read-property-set">  <Read>    <Name ref="set-ref">environment.name</Name>    <Key ref="key-ref">request.headers.api-version</Key>    <AssignTo>target_url</AssignTo>    <DefaultValue>https://httpbin.org/get</DefaultValue>  </Read>  <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables></ReadPropertySet>

Child element reference

This section describes the child elements of<ReadPropertySet>.

<Read>

Resolves a property set variable and sets the result in a flow variable.

The<Read> element specifes the property set variable to resolve and the flow variable to set that value to. It also includes an optional default value, which is used in the event of an unresolved property set. You can include multiple<Read> elements in a single<ReadPropertySet> policy.

Default ValueN/A
Required?Optional
TypeComplex type
Parent Element<ReadPropertySet>
Child Elements<Name>
<Key>
<AssignTo>
<DefaultValue>

The<Read> element uses the following syntax:

Syntax

<Read><Nameref="set-ref">property-set-name</Name><Keyref="key-ref">key-name</Key><AssignTo>var1</AssignTo><DefaultValue>default-value</DefaultValue></Read>

Example

This example uses<ReadPropertySet> to getpropertyset.environment.name.request.headers.api-version and assign it totarget_url. If the property set value isn't obtained,https://httpbin.org/get is used instead.

<ReadPropertySet name="read-property-set">  <Read>    <Name ref="environment.name">my-property-set-name</Name>    <Key ref="request.headers.api-version">my-property-set-key</Key>    <AssignTo>target_url</AssignTo>    <DefaultValue>https://httpbin.org/get</DefaultValue>  </Read>  <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables></ReadPropertySet>

The following table provides a high-level description of the child elements of<Read>.

Child ElementRequired?Description
<Name>RequiredString

The property set to read from. Provide theref, value, or both.

Apigee first tries to resolve theName based on theref, then the value. If neither is resolvable, the<DefaultValue>, if provided, applies.

<Name> and<Key> combine topropertyset.{value_resolved_from_Name}.{value_resolved_from_Key}.

<Key>RequiredString

The key of the property set that is used when resolving the variable. Provide theref, value, or both.

Apigee first tries to resolve theKey based on theref, then the value. If neither is resolvable, the<DefaultValue>, if provided, applies.

<Name> and<Key> combine topropertyset.{value_resolved_from_Name}.{value_resolved_from_Key}.

<AssignTo>RequiredString

Specifies the flow variable to assign the resolved variable to.
<DefaultValue>OptionalString

Specifies a default value to use when the variable cannot be resolved.

<IgnoreUnresolvedVariables>

Determines whether processing stops when a property set is unresolved. Set totrue to ignore unresolved variables and continue processing.

IgnoreUnresolvedVariables is not applicable when<DefaultValue> is provided.

Default ValueFalse
Required?Optional
TypeBoolean
Parent Element<ReadPropertySet>
Child Elements None

Error reference

This section describes the fault codes and error messages that are returned and fault variables that are set by Apigee specific to the<ReadPropertySet> policy. This information is important to know if you are developing fault rules to handle faults. To learn more, seeWhat you need to know about policy errors andHandling faults.

Runtime errors

These errors can occur when the policy executes.

Fault codeHTTP statusCause
steps.readpropertyset.UnresolvedVariable500

This error occurs if a variable specified in the ReadPropertySet policy is either:

  • Out of scope (not available in the specific flow where the policy is being executed)
  • or
  • Can't be resolved (is not defined).

If<IgnoreUnresolvedVariables> is false and<DefaultValue> is not specified, the resolution fails.

Deployment errors

These errors can occur when you deploy a proxy containing this policy.

Error nameCause
steps.readpropertyset.EmptyReadsThe policy has no<Read> child elements.
steps.readpropertyset.FieldUnsetThis code is returned when any of these are true:
  • Neither a reference nor name is set for<Name>
  • Neither a reference nor name is set for<Key>
  • No value was provided for<AssignTo>

Fault variables

These variables are set when this policy triggers an error at runtime. For more information, seeWhat you need to know about policy errors.

VariablesWhereExample
fault.name="FAULT_NAME"FAULT_NAME is the name of the fault, as listed in theRuntime errors table above. The fault name is the last part of the fault code.fault.name Matches "UnresolvedVariable"
readpropertyset.POLICY_NAME.failedPOLICY_NAME is the user-specified name of the policy that threw the fault.readpropertyset.RPS-SetResponse.failed = true

Example error response

Note: For error handling, the best practice is to trap theerrorcode part of the error response. Do not rely on the text in thefaultstring, because it could change.
{"fault":{"faultstring":"ReadPropertySet[RPS-SetResponse]: unable to resolve variable [variable_name]","detail":{"errorcode":"steps.readpropertyset.UnresolvedVariable"}}}

Example fault rule

  <FaultRule name="ReadPropertySet Faults">      <Step>          <Name>RPS-CustomSetVariableErrorResponse</Name>          <Condition>(fault.name = "SetVariableFailed")</Condition>      </Step>      <Condition>(readpropertyset.failed = true)</Condition>  </FaultRule>

Schemas

Each policy type is defined by an XML schema (.xsd). For reference,policy schemas are available on GitHub.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-17 UTC.