Invoke-RestMethod
Call a JSON API
Invoke-RestMethod -Uri 'https://example.com'
- Works on
- WindowsLinuxmacOS
- PowerShell
- 5.1 and later
- Reference
- Microsoft Learn: Invoke-RestMethod
Like Invoke-WebRequest, but if the body is JSON you get objects back. Use -Method Post and -Body for writes. Do not put tokens in scripts you commit.
Try this
Invoke-RestMethod -Uri 'https://example.com' | Get-Member
Coming from another shell
| Shell | What you might type |
|---|---|
| bash / zsh | curl -s https://api.example.com/items | jq |
More in From bash and From cmd.