Prefer Header

Prefer Header

The OData specification defines the Prefer HTTP header to customize the behavior of certain operations.
The PROLIN Power Server REST API supports two categories of Prefer header values:

  • Return preferences (for data-altering operations)
  • Conflict-resolution preferences (for attachment uploads)

Return Preferences

Used with PUT, POST, and PATCH operations to define how the server should respond after altering data.

Preference Description
return=minimal The response should not include the modified object. Returns HTTP 204 (No Content) on success.
return=representation The response should include the altered object. Returns HTTP 200 (OK) or HTTP 201 (Created).

Example

PATCH http://myserver:5181/odata/ServiceRequests(139239)
Prefer: return=representation
Content-Type: application/json

{
  "Description": "Printer cleaned and tested successfully."
}

⚠️ Note:
The returned object may not fully reflect the final state after database rules (DB Rules) are applied.
To ensure accuracy, perform a subsequent GET operation using the object’s Uid.


Conflict-Resolution Preferences

⚠️ Currently supported only for attachment uploads.

When uploading attachments, naming conflicts may occur if a file with the same name already exists.
The conflict-resolution preference controls how the API handles these conflicts.

Preference Description
conflict-resolution=replace Replaces the existing file with the new one. Responds with HTTP 200 (OK) if replaced, or HTTP 201 (Created) if new.
conflict-resolution=rename Automatically renames the new file by adding a sequence suffix (e.g., _1). Always returns HTTP 201 (Created).
conflict-resolution=none No conflict resolution. If a name conflict occurs, responds with HTTP 409 (Conflict). (Default behavior)

Example (Attachment Upload with Conflict Resolution)

POST http://myserver:5181/odata/Problems(7403319703)/Attachments
Authorization: Bearer <ACCESS_TOKEN>
Content-Type: multipart/form-data; boundary=-------------------------acebdf13572468
Prefer: conflict-resolution=replace

---------------------------acebdf13572468
Content-Disposition: form-data; name="file"; filename="myfile.txt"
Content-Type: text/plain

<File Content Here>
---------------------------acebdf13572468--

💡 Tip:
Use return=representation during development for easier debugging,
and return=minimal in production for faster performance and smaller payloads.

Back to top