put vs patch rest call difference with example?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2019 08:13 PM
put vs patch rest call difference with example?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2019 11:22 PM
Hi,
In the REST world, PUT and PATCH have different semantics. PUT means replace the entire resource with given data (so null out fields if they are not provided in the request), while PATCH means replace only specified fields. For the Table API, however, PUT and PATCH mean the same thing. PUT and PATCH modify only the fields specified in the request.
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 my answer is worthy,mark it as correct and helpful.
Regards,
Pratiksha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2019 08:52 PM
Hi,
There are no differences in ServiceNow between PATCH and PUT.
https://hi.service-now.com/kb_view.do?sysparm_article=KB0534905
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2019 11:38 PM
Hi Mallikharjuna,
see below links and it should be helpful
https://hi.service-now.com/kb_view.do?sysparm_article=KB0534905
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2019 12:18 AM
Hi Mallikharjuna,
Any update on this?
Can you mark my answer as correct, helpful if you were able to achieve the requirement and close the thread
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader