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 2000 entities.
For example, consider a client that specifies the following header while accessing a collection of 3000 entities:
Prefer: odata.maxpagesize=1000
In this case, the server changes its default page size and generates the nextLink after 1000 entities in a collection. In its response, the server sends back the prefer header odata.maxpagesize=1000, which indicates that the preference is applied. Use the nextLink to get the next 1000 entities.
In the same example, if the client specifies odata.maxpagesize=2500, the server restricts the page size to 2000 entities in the collection. It generates a nextLink URL to the next 1000 and sends back the odata.maxpagesize=2000 indicating the preference that was applied.
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.