liveBook · Manning

HTTP PUT method

As explained in Pro ASP.NET Core 7, Tenth Edition

The HTTP PUT method requests replacement of a resource with the representation supplied by the client.

HTTP PUT sends a replacement representation for an existing resource. In an ASP.NET Core products API, an action restricted to PUT receives a Product from the request body through model binding and updates the database. section 19.4.2

Listing 19.12 Updating an object
Invoke-RestMethod http://localhost:5000/api/products -Method PUT -Body  (@{ 
ProductId=1; Name="Green Kayak"; Price=275; CategoryId=1; SupplierId=1} | 
ConvertTo-Json) -ContentType "application/json"

The PowerShell request sends JSON to /api/products with ProductId=1 and replacement property values. Requesting the products collection afterward lets you check the change. section 19.4.2

How Pro ASP.NET Core 7, Tenth Edition covers it

How deep it goes
Shows request-body model binding and a runnable update test, while deferring detailed model binding and validation.
Examples
Tests a JSON replacement Product with PowerShell Invoke-RestMethod, then checks the products collection in a browser.
What it assumes
Assumes a working ASP.NET Core products API and introduces request-body binding through its update action.
What you can do after
Apply it via ASP.NET Core MVC to receive a replacement Product and update the database.
How it connects
Connects HTTP PUT to controller actions, model binding, Entity Framework Core, and HTTP GET verification.

Also explained in

Compare how 8 books explain HTTP PUT method →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pro ASP.NET Core 7, Tenth Edition. The section links point to the parts of the book it draws on.