Validate OData request
APPLIES TO: All API Management tiers
The validate-odata-request
policy validates the request URL, headers, and parameters of a request to an OData API to ensure conformance with the OData specification.
Policy statement
<validate-odata-request error-variable-name="variable name" default-odata-version="OData version number" min-odata-version="OData version number" max-odata-version="OData version number" max-size="size in bytes" />
Attributes
Attribute | Description | Required | Default |
---|---|---|---|
error-variable-name | Name of the variable in context.Variables to log validation errors to. |
No | N/A |
default-odata-version | The default OData version that is assumed for parameter validation if the request doesn't contain an OData-Version header. |
No | 4.0 |
min-odata-version | The minimum OData version in the OData-Version header of the request that the policy accepts. |
No | N/A |
max-odata-version | The maximum OData version in the OData-Version header of the request that the policy accepts. |
No | N/A |
max-size | Maximum size of the request payload in bytes. | No | N/A |
Usage
- Policy sections: inbound
- Policy scopes: global, workspace, product, API
- Gateways: classic, v2, consumption, self-hosted, workspace
Usage notes
- Configure the policy for an OData API that has been imported to API Management.
- This policy can only be used once in a policy section.
Example
The following example validates a request to an OData API and assumes a default OData version of 4.01 if no OData-Version
header is present:
<validate-odata-request default-odata-version="4.01" />
Related policies
Related content
For more information about working with policies, see:
- Tutorial: Transform and protect your API
- Policy reference for a full list of policy statements and their settings
- Policy expressions
- Set or edit policies
- Reuse policy configurations
- Policy snippets repo
- Author policies using Microsoft Copilot in Azure