Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

How to PATCH in Web API and OData

$
0
0

From reading the RFC specification of the Patch verb it's clear that the `Patch` verb shouldn't get values to partially update the entity but operations to make:

"...With PATCH, however, the enclosed entity contains a set
of instructions describing how a resource currently residing on the
origin server should be modified to produce a new version."

In MSDN for the Delta<T> class it's also clear, as the Patch description says:

"Overwrites the original entity with the **changes tracked** by this Delta"

Unlike the description of Put:

"Overwrites the original entity with the **values** stored in this Delta."


So far so good, but I couldn't find a way to send those "instructions" with OData, No matter what I do, Delta<T>.Patch only replaces the values.

What should be the syntax of Patch request?

The ways I tried were:

PATCH http://localhost:55783/Products(1) HTTP/1.1
User-Agent: Fiddler
Host: localhost:55783
Content-Length: 19
Content-type: application/json

{ "Price": 432 }



And

{ "op": "add", "path": "/Price", "value": 423432 }


And stuff near that.

(Stackoverflow thread)


Viewing all articles
Browse latest Browse all 4850

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>