Tutorial by Examples

Define your payload to send for possible more complex data $Payload = @{ text="test string"; username="testuser" } Use ConvertTo-Json cmdlet and Invoke-RestMethod to execute the call Invoke-RestMethod -Uri "https://hooks.slack.com/services/yourwebhookstring" -Metho...
$params = @{ Uri = "https://your.hipchat.com/v2/room/934419/notification?auth_token=???" Method = "POST" Body = @{ color = 'yellow' message = "This is a test message!" notify = $false message_format = "text" ...
GET your REST data and store in a PowerShell object: $Post = Invoke-RestMethod -Uri "http://jsonplaceholder.typicode.com/posts/1" Modify your data: $Post.title = "New Title" PUT the REST data back $Json = $Post | ConvertTo-Json Invoke-RestMethod -Method Put -Uri "h...
GET 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 = "[email protected]" $Users[1].name = "Jane S...
Identify the item that is to be deleted and delete it: Invoke-RestMethod -Method Delete -Uri "http://jsonplaceholder.typicode.com/posts/1"

Page 1 of 1