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. The services built with Windchill REST Services have a default 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 of 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 100000 entities. The maximum accepted value for
odata.maxpagesize is controlled by the
maxPageSize property, which has an upper limit of 100000. For more information on the
maxPageSize property, see
Windchill REST Services OData Properties.
In odata.properties, you can configure the default page size value and maximum page size value while making a request:
• If not specified, the default value of maxPageSize is 2000. It can be set to any value up to a maximum of 100000.
• If not specified, the default value of defaultPageSize is 25. Once the value is set, it should be applied to all WRS endpoints that support pagination.
|
The odata.maxpagesize value specified in the Prefer header, while making a request, overrides the defaultPageSize value.
|
For example, consider a client that specifies the following Prefer 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.
For more information, see the
Preference maxpagesize section of the OData specifications.
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.