Using REST with PowerShell Objects to GET and POST many items
suggest changeGET your REST data and store in a PowerShell object:
$Users = Invoke-RestMethod -Uri "http://jsonplaceholder.typicode.com/users"
Modify many items in your data:
$Users[0].name = "John Smith"
$Users[0].email = "John.Smith@example.com"
$Users[1].name = "Jane Smith"
$Users[1].email = "Jane.Smith@example.com"
POST all of the REST data back:
$Json = $Users | ConvertTo-Json
Invoke-RestMethod -Method Post -Uri "http://jsonplaceholder.typicode.com/users" -Body $Json -ContentType 'application/json'
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents