Difference between PUT and PATCH in REST API?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2019 05:01 AM
Hi All
I have read put and patch do more or less the same thing. So why do use two different methods for doing the same thing essentially?
Can we also Insert using PATCH method?
- Labels:
-
Team Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2019 05:03 AM
Hi,
PUT means replace the entire resource with given data (so null out fields if they are not provided in therequest), while PATCH means replace only specified fields. For the Table API, however, PUT and PATCH mean the same thing.
For any more information, please check the following documentation:
https://hi.service-now.com/kb_view.do?sysparm_article=KB0534905
If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
Thank you
Cheers
Alberto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2024 09:07 PM
Shame that KB article is for internal use only. Us mere mortals are denied access.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2019 05:10 AM
Hi Rahul,
In REST API ,
Patch will updates the whole record fields.
Put will work on specific field you want to update.
Thanks,
-Priyanka

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2019 05:11 AM
Hi ,
PATCH: it is used to update an existing entity with new information. You can't patch an entity that doesn't exist. You would use this when you have a simple update to perform, e.g. changing a user's name.
partially updates the resource into the server mapped by the provided data. As an example, PATCH /api/log/1 will only update properties mapped in the request body. Just like the PUT method it may include an If-Match with the ETag and in case of success 200 Ok or 202 Accepted with the new ETag value should be returned, or in case of a failure a 404 Not Found or 409 Conflict will be indicated with the same conditions as the PUT method. This about it like a partial update to a row in a table, where only some columns are affected.
PUT: it is used to set an entity's information completely. PUTting is similar to POSTing, except that it will overwrite the entity if already exists or create it otherwise. You could use a PUT to write a user to your database that may already be in it.
replaces the existing resource by the new one. As an example, PUT /api/log/1 will completely replace that resource for the new one. Optionally in the request you may include an If-Match with the ETag value to be sure you are replacing the expected version of that resource (preventing concurrency problems). In case of success, it should return a 200 Ok or 202 Accepted (async operations) with the new ETag. In case the entity does not exist, a 404 Not Found must be returned or a 409 Conflict if the version or any other value in the entity are not correct with internal server state (like referenced links). Think about it like an update to a complete row in a table;
If you have some time so go through these below links .
https://www.quora.com/What-is-the-difference-between-PUT-POST-and-PATCH-for-RESTful-APIs
https://community.servicenow.com/community?id=community_question&sys_id=229a832ddb5cdbc01dcaf3231f9619e2
Here FAQ is ther
https://hi.service-now.com/kb_view.do?sysparm_article=KB0534905
If it is helping to you please mark as correct and also helpful.
Thanks
Sanjay bagri