Please read the online documentation: Invoke-RestMethod
Here is a sample showing how to access the data returned from this API:
$uri = 'api.spotcrime.com/crimes.json'
$params = @{
lat = '30.639155'
lon = '-96.3647937'
radius = '0.02'
key = 'spotcrime-private-api-key'
}
$crimes = Invoke-RestMethod -Uri $uri -Body $params |
Select-Object -ExpandProperty crimes
$crimes | Format-Table -AutoSize
In this dataset we have an object named crimes which contains an array of records. Expanding the crimes object and storing it to a $crimes
variable will allow us to work with the records more easily.
Notice how Invoke-RestMethod
automatically detects and converts JSON into objects. No need to use ConvertFrom-Json
.
get-help invoke-restmethod
or search for the documentation on the Internet. – theglauber