Skip to content

InvokeNetboxRequest

Since

v1.0.4

SYNOPSIS

Invokes a REST API request to Netbox.

SYNTAX

InvokeNetboxRequest [-URI] <UriBuilder> [[-Headers] <Hashtable>] [[-Body] <Object>] [[-Timeout] <UInt16>] [[-Method] <String>] [-Raw] [-All] [[-PageSize] <Int32>] [[-MaxRetries] <Int32>] [[-RetryDelayMs] <Int32>] [[-Branch] <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]

DESCRIPTION

Core function for all Netbox API communication. Handles authentication, retry logic for transient failures, and comprehensive error handling. Cross-platform compatible (Windows, Linux, macOS).

Supports automatic pagination when -All is specified for GET requests.

EXAMPLES

EXAMPLE 1

$result = InvokeNetboxRequest -URI $uri -Method GET

EXAMPLE 2

$result = InvokeNetboxRequest -URI $uri -Method GET -All Fetches all pages of results automatically.

EXAMPLE 3

$result = InvokeNetboxRequest -URI $uri -Method POST -Body $data -MaxRetries 5

PARAMETERS

-URI

The URI builder object containing the API endpoint.

```yaml Type: UriBuilder Parameter Sets: (All) Aliases:

Required: True Position: 1 Default value: None Accept pipeline input: False Accept wildcard characters: False ```

-Headers

Additional headers to include in the request.

```yaml Type: Hashtable Parameter Sets: (All) Aliases:

Required: False Position: 2 Default value: @{} Accept pipeline input: False Accept wildcard characters: False ```

-Body

The request body for POST/PATCH/PUT requests.

```yaml Type: Object Parameter Sets: (All) Aliases:

Required: False Position: 3 Default value: None Accept pipeline input: False Accept wildcard characters: False ```

-Timeout

Request timeout in seconds. Defaults to module timeout setting.

```yaml Type: UInt16 Parameter Sets: (All) Aliases:

Required: False Position: 4 Default value: (Get-NBTimeout) Accept pipeline input: False Accept wildcard characters: False ```

-Method

HTTP method (GET, POST, PATCH, PUT, DELETE, OPTIONS).

```yaml Type: String Parameter Sets: (All) Aliases:

Required: False Position: 5 Default value: GET Accept pipeline input: False Accept wildcard characters: False ```

-Raw

Return the raw API response instead of just the results array.

```yaml Type: SwitchParameter Parameter Sets: (All) Aliases:

Required: False Position: Named Default value: False Accept pipeline input: False Accept wildcard characters: False ```

-All

Automatically fetch all pages of results for GET requests. Uses the 'next' field in API response to paginate.

```yaml Type: SwitchParameter Parameter Sets: (All) Aliases:

Required: False Position: Named Default value: False Accept pipeline input: False Accept wildcard characters: False ```

-PageSize

Number of items per page when using -All. Default: 100. Range: 1-1000.

```yaml Type: Int32 Parameter Sets: (All) Aliases:

Required: False Position: 6 Default value: 100 Accept pipeline input: False Accept wildcard characters: False ```

-MaxRetries

Maximum number of retry attempts for transient failures. Default: 3.

```yaml Type: Int32 Parameter Sets: (All) Aliases:

Required: False Position: 7 Default value: 3 Accept pipeline input: False Accept wildcard characters: False ```

-RetryDelayMs

Initial delay between retries in milliseconds. Uses exponential backoff. Default: 1000.

```yaml Type: Int32 Parameter Sets: (All) Aliases:

Required: False Position: 8 Default value: 1000 Accept pipeline input: False Accept wildcard characters: False ```

-Branch

{{ Fill Branch Description }}

```yaml Type: String Parameter Sets: (All) Aliases:

Required: False Position: 9 Default value: None Accept pipeline input: False Accept wildcard characters: False ```

-ProgressAction

{{ Fill ProgressAction Description }}

```yaml Type: ActionPreference Parameter Sets: (All) Aliases: proga

Required: False Position: Named Default value: None Accept pipeline input: False Accept wildcard characters: False ```

CommonParameters

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

INPUTS

OUTPUTS

[PSCustomObject] The API response or results array.

NOTES

AddedInVersion: v1.0.4

Common parameters

common request params