Invoke-BirdWeatherRESTRequest

SYNOPSIS

Makes an API request to BirdWeather

SYNTAX

__AllParameterSets

Invoke-BirdWeatherRESTRequest [[-Method] <string>] [-ResourceURI] <string>
 [[-UriFilter] <hashtable>] [[-MultiValueParameter] <string[]>] [[-Headers] <hashtable>]
 [[-Data] <Object>] [[-InFile] <string>] [[-ContentType] <string>] [[-Token] <string>]
 [[-Pagination] <string>] [[-ResultProperty] <string>] [-AllResults] [-Raw]

ALIASES

This cmdlet has the following aliases,

  • Invoke-BWRRequest

DESCRIPTION

The Invoke-BirdWeatherRESTRequest cmdlet invokes an API request to the BirdWeather REST API

This is an internal function that is used by all public functions

GET requests are read-only. Any other request is a write request and is never retried

Station endpoints use the station token (or the station ID when an administrator token is used) as part of the resource path. Use the {token} placeholder in the ResourceURI and the Token parameter so that the token is never written to the verbose output, error messages, or the debug variable

EXAMPLES

EXAMPLE 1

Invoke-BirdWeatherRESTRequest -ResourceURI '/species/120' -ResultProperty 'species'

Returns the species with the ID 120

EXAMPLE 2

Invoke-BirdWeatherRESTRequest -ResourceURI '/stations/{token}/detections' -UriFilter @{ limit = 100 } -ResultProperty 'detections' -Pagination Cursor -AllResults

Returns every detection of the station that is defined by the stored API token by following the pagination

EXAMPLE 3

Invoke-BirdWeatherRESTRequest -Method POST -ResourceURI '/stations/{token}/config' -Token 'abc123' -Data @{ name = 'My station' }

Sends a write request with a JSON body

PARAMETERS

-AllResults

Returns all items from an endpoint by following the pagination

Ignored for write requests

Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-ContentType

Defines the content type of the InFile request body

Default value: application/octet-stream

Type: System.String
DefaultValue: application/octet-stream
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 7
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Data

Optional object to send as the JSON request body

A string is sent as is and must already be JSON, any other object is converted to JSON Dates are converted to UTC ISO 8601 strings

Type: System.Object
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 5
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Headers

Hashtable of additional request headers

The Authorization header cannot be overwritten

Type: System.Collections.Hashtable
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 4
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-InFile

Optional path of a file to send as the binary request body

Used with the ContentType parameter, such as when uploading a soundscape

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 6
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Method

Defines the type of API method to use

Allowed values: ‘GET’, ‘POST’, ‘PUT’, ‘PATCH’, ‘DELETE’

Type: System.String
DefaultValue: GET
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 0
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-MultiValueParameter

Defines the names of the UriFilter keys that must be sent as repeated key\value pairs instead of a comma separated list

Type: System.String[]
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 3
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Pagination

Defines how an endpoint is paged when using AllResults

Cursor - the cursor parameter is set to the ID of the last item that was returned
Page   - the page parameter is increased by one

Allowed values: ‘Cursor’, ‘Page’

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 9
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Raw

Returns the full API response object instead of only the results

Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-ResourceURI

Defines the resource uri (url) path to use when creating the API call

The path is appended to the base URI defined by Add-BirdWeatherBaseURI The {token} placeholder is replaced with the Token parameter

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 1
  IsRequired: true
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-ResultProperty

Defines the name of the property of the API response that contains the results, such as detections or species

When not defined every property except success is returned

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 10
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Token

Defines the station token (or station ID with an administrator token) that replaces the {token} placeholder of the ResourceURI

By default the API token defined by Add-BirdWeatherAPIKey is used

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 8
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-UriFilter

Hashtable of query string parameters to append to the resource uri

Arrays are sent as comma separated lists, dates are converted to UTC, and booleans are sent as lowercase true\false values

Type: System.Collections.Hashtable
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 2
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

NOTES

N/A