Total Downloads

2,596,730

Total Files

9,206

Latest Update

10

How to do partial updates to REST API resources

Posted July 10, 2017 | Windows


The HTTP verb named PATCH can be used for partial updates, i.e., when you would like to update just a few fields of a resource. While you could update a resource “partially” using HTTP PUT, by sending the entire resource with the updated values, that is potentially problematic. At the very least, you might end up consuming more network bandwidth than necessary.

For partial updates, HTTP PATCH is easier and safer, and ASP.NET Web API provides excellent support for HTTP PATCH requests. This article will discuss how we can use PATCH to perform partial updates when working with RESTful services using Web API.

PATCH vs. PUT

The HTTP PATCH method should be used whenever you would like to change or update just a small part of the state of the resource. You should use the PUT method only when you would like to replace the resource in its entirety. Note that PATCH is not a replacement for PUT or POST, but just a way of applying a delta update to a resource representation. Roy Fielding, who authored the REST architectural style and many web standards, said that he created PATCH because “partial PUT is never RESTful.”

Let’s look at a good example of a PATCH request. Imagine you have a model named Customer and not all of its members are editable. ASP.NET Web API incorporates nice support for HTTP PATCH requests using the Delta<T> class, which was included as part of the OData additions. We will cover how to use the Delta<T> class in a later post. In the section that follows, we will examine how we can implement HTTP PATCH support in Web API in the simplest way.



Source link

')
ankara escort çankaya escort çankaya escort escort bayan çankaya istanbul rus escort eryaman escort ankara escort kızılay escort istanbul escort ankara escort ankara escort escort ankara istanbul rus Escort atasehir Escort beylikduzu Escort Ankara Escort malatya Escort kuşadası Escort gaziantep Escort izmir Escort