OData Prefer Headers
OData enables clients to request a preferred service behavior by specifying Prefer header in requests. In some cases, the service may not apply the preference specified by the client. However, the service in its response indicates the preference that was applied. OData supports many Prefer header values.
This section provides information about the preferences supported by Windchill REST Services.
Preference maxpagesize
The odata.maxpagesize preference enables clients to change the pagination behavior of the server. By default, services built with Windchill REST Services have a page size of 25 entities. If the client does not specify this preference, then in response to a GET request for a collection, Windchill REST Services generates a nextLink URL in the response if the number entities in the collection are greater than 25. Clients can use this URL to get to the next page of entities in the collection. With the odata.maxpagesize preference, the client can change the page size of the server to a maximum value of 10000 entities.
For example, consider a client that specifies the following header while accessing a collection of 15000 entities:
Prefer: odata.maxpagesize=5000
In this case, the server changes its default page size and generates the nextLink after 5000 entities in a collection. In its response, the server sends back the prefer header odata.maxpagesize=5000, which indicates that the preference is applied. Use the nextLink to get the next 5000 entities.
In the same example, if the client specifies odata.maxpagesize=10500, the server restricts the page size to 10000 entities in the collection. It generates a nextLink URL to the next 5000 and sends back the odata.maxpagesize=10000 indicating the preference that was applied.
• You can set defaultPageSize and maxPageSize to 25 and 2000, respectively.
• In the odata.properties properties, you can configure the maximum PageSize value and the default page size value while making a request.
• The default value for maxPageSize is 2000. It can be set to any value, up to a maximum of 100000.
• The default value for defaultPageSize is 25. Once value is set, it should be applied to all WRS end points that support pagination
• The upper limit for maxPageSize is 100000.
• The odata.maxpagesize value specified in Prefer Header, while making a request, overrides the default PageSize value.
Preferences return=representation and return=minimal
The return=representation and return=minimal preferences enable clients to decide if the response should contain the modified content. If none of these preferences are specified, then the default preference return=representation is used to return the content.
• return=representation—The request returns the modified content in the body of the response. It also returns the appropriate HTTP status code.
• return=minimal—The request does not return the modified content in the body of the response. It only returns the appropriate HTTP status code.