function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sujesh RamachandranSujesh Ramachandran 

Difference between @Httpput and @HttpPatch Rest Annotations?

Hi All,

 

Could anyone share the difference between @Httpput and @HttpPatch Rest Annotations.

 

Thanks,

Sujesh

sfdcfoxsfdcfox
The former responds to a PUT command, such as:

PUT /services/apexrest/abc/doput HTTP/1.1

It is used for inserting new resources or updating existing resources (per RFC 2616).

The latter responds to PATCH requests, such as:

PATCH /services/apexrest/abc/dopatch HTTP/1.1

PATCH is a command used for a "partial update to an existing resource," per RFC 5789 (and others).

In summary, use PUT for API requests that should create new data, and PATCH for API requests that should update existing data.