Get-NBRequestHeaders
Since
v4.5.2.0
SYNOPSIS
Get standard request headers for Netbox API calls
SYNTAX
Get-NBRequestHeaders [[-Branch] <String>] [-SkipBranchContext] [-ProgressAction <ActionPreference>]
[<CommonParameters>]
DESCRIPTION
Returns a hashtable containing the Authorization header (with proper v1/v2 token format) and optionally the X-NetBox-Branch header if a branch context is active.
This function centralizes header construction to ensure consistent authentication and branch context handling across all API request functions.
EXAMPLES
EXAMPLE 1
$headers = Get-NBRequestHeaders
Invoke-WebRequest -Uri $uri -Headers $headers
EXAMPLE 2
``` $headers = Get-NBRequestHeaders -Branch "abc123"
Uses explicit branch instead of stack context
```
EXAMPLE 3
``` $headers = Get-NBRequestHeaders -SkipBranchContext
Only returns Authorization header, no branch context
```
PARAMETERS
-Branch
Optional explicit branch schema_id to use instead of the stack context
```yaml Type: String Parameter Sets: (All) Aliases:
Required: False Position: 1 Default value: None Accept pipeline input: False Accept wildcard characters: False ```
-SkipBranchContext
If specified, omits the X-NetBox-Branch header from the returned headers.
```yaml Type: SwitchParameter Parameter Sets: (All) Aliases:
Required: False Position: Named Default value: False 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
System.Collections.Hashtable
NOTES
AddedInVersion: v4.5.2.0