Bug Description
For some reason, when attempting to modify the lag of an existing interface using Set-NBDCIMInterface I am getting an HTTP 403 Forbidden error from the API. If I attempt to replicate the same PATCH request using the Swagger UI and the same API key, it succeeds with a 200 OK.
Function/Cmdlet Affected
- Function: Set-NBDCIMInterface
- Module: DCIM
Steps to Reproduce
- Connect to Netbox:
Connect-NBAPI -Hostname '...' -Credential $cred
- Run command:
Set-NBDCIMInterface -Id 382 -LAG 37919 -Verbose
- See error:
Expected Behavior
The interface is updated with the referenced LAG.
Actual Behavior
Set-NBDCIMInterface -Id 382 -LAG 37919 -Verbose
VERBOSE: Updating D CI MI nt er fa ce
VERBOSE: Retrieving DCIM Interface
VERBOSE: Building URI components
VERBOSE: Adding ID to segments
VERBOSE: Building URI
VERBOSE: Checking connection status
VERBOSE: URIPath: api/dcim/interfaces/382/
VERBOSE: Completed building URIBuilder
VERBOSE: Getting Netbox Timeout
VERBOSE: Getting Netbox InvokeParams
VERBOSE: [1/3] GET https://dev.netbox.domain.tld/api/dcim/interfaces/382/
VERBOSE: Requested HTTP/1.1 GET with 0-byte payload
VERBOSE: Received HTTP/1.1 1426-byte response of content type application/json
VERBOSE: Content encoding: utf-8
VERBOSE: No 'results' property found, returning full response
VERBOSE: Building URI components
VERBOSE: Adding lag parameter
VERBOSE: Building URI
VERBOSE: Checking connection status
VERBOSE: URIPath: api/dcim/interfaces/382/
VERBOSE: Completed building URIBuilder
VERBOSE: Performing the operation "Set" on target "Interface ID 382".
VERBOSE: Getting Netbox Timeout
VERBOSE: Getting Netbox InvokeParams
VERBOSE: BODY: {"lag":37919}
VERBOSE: [1/3] PATCH https://dev.netbox.domain.tld/api/dcim/interfaces/382/
VERBOSE: Requested HTTP/1.1 PATCH with 13-byte payload
VERBOSE: Received HTTP/1.1 63-byte response of content type application/json
VERBOSE: Extracting error body from HttpResponseMessage (PowerShell Core)
VERBOSE: Could not read response body: Exception calling "ReadAsStringAsync" with "0" argument(s): "Cannot access a disposed object.
Object name: 'System.Net.Http.HttpConnectionResponseContent'."
InvokeNetboxRequest: Netbox API Error: 403 Forbidden Endpoint: PATCH
https://dev.netbox.domain.tld/api/dcim/interfaces/382/ Message: Response status code does
not indicate success: 403 (Forbidden). Troubleshooting: - Verify your API token has permission for
this operation - Check object-level permissions in Netbox - Ensure the token user has the required role
Environment
- PowerNetbox Version: 4.5.6.0
- Netbox Version: 4.4.10
- PowerShell Version: 7.5.3
- PowerShell Edition: Core
- OS: Ubuntu 24.04.3 LTS on WSL2
Additional Context
I copied the body from the verbose output and used it in the Swagger UI on the PATCH /api/dcim/interfaces/{id}/ endpoint and the request was successful:
curl -X 'PATCH' \
'https://dev.netbox.domain.tld/api/dcim/interfaces/382/' \
-H 'accept: application/json' \
-H 'Authorization: <redacted>' \
-H 'Content-Type: application/json' \
-H 'X-CSRFTOKEN: <redacted>' \
-d '{"lag":37919}'
Possible Solution (optional)
Bug Description
For some reason, when attempting to modify the lag of an existing interface using
Set-NBDCIMInterfaceI am getting an HTTP 403 Forbidden error from the API. If I attempt to replicate the same PATCH request using the Swagger UI and the same API key, it succeeds with a 200 OK.Function/Cmdlet Affected
Steps to Reproduce
Connect-NBAPI -Hostname '...' -Credential $credSet-NBDCIMInterface -Id 382 -LAG 37919 -VerboseExpected Behavior
The interface is updated with the referenced LAG.
Actual Behavior
Environment
Additional Context
I copied the body from the verbose output and used it in the Swagger UI on the PATCH
/api/dcim/interfaces/{id}/endpoint and the request was successful:Possible Solution (optional)