Bug Description
Get-NBContactAssignment and New-NBContactAssignment are using the parameter name "Content_Type" instead of "Object_Type", which is the correct field name in the Netbox API. This causes confusion and potential errors when users try to filter or create contact assignments based on the object type.
Function/Cmdlet Affected
- Function: Get-NBContactAssignment, New-NBContactAssignment
- Module: DCIM, Tenancy and others
Steps to Reproduce
- Connect to Netbox:
Connect-NBAPI -Hostname '...' -Credential $cred
- Run command:
New-NBContactAssignment -Content_Type 'dcim.site' -Object_Id 1 -Contact 2 -Role 3
- See error
Expected Behavior
This should create a new contact assignment by using 'Object_Type', 'Object_Type_Id' as function parameters (and when calling API).
Actual Behavior
Currently the functions use parameter 'Content_Type' which do not match the API field names, leading to errors.
InvokeNetboxRequest: Netbox API Error: 400 Bad Request Endpoint: POST https://localhost:8000/api/tenancy/contact-assignments/ Message: object_type: This field is required. Troubleshooting: - Check your request
parameters - Verify the API endpoint exists
Environment
- PowerNetbox Version: 4.5.8.1
- Netbox Version: 4.4.9 (Docker) and 4.5.3
- PowerShell Version: 5.1.26100.8115 and 7.6.1
- PowerShell Edition: Desktop and Core
- OS: Windows 11
Additional Context
A similar issue affects Get-NBContactAssignment with parameter Content_Type_Id.
The wrong behaviour is not caught by module tests. There, the invalid API parameter is checked for presence. IntegrationTests.ps1 does not have tests for contact assignments.
Possible Solution (optional)
I will provide a PR fixing the issue.
- Fix function parameters to 'Object_Type' and 'Object_Type_id'
- Add integration tests for the contact assignment functions
Bug Description
Get-NBContactAssignment and New-NBContactAssignment are using the parameter name "Content_Type" instead of "Object_Type", which is the correct field name in the Netbox API. This causes confusion and potential errors when users try to filter or create contact assignments based on the object type.
Function/Cmdlet Affected
Steps to Reproduce
Connect-NBAPI -Hostname '...' -Credential $credNew-NBContactAssignment -Content_Type 'dcim.site' -Object_Id 1 -Contact 2 -Role 3Expected Behavior
This should create a new contact assignment by using 'Object_Type', 'Object_Type_Id' as function parameters (and when calling API).
Actual Behavior
Currently the functions use parameter 'Content_Type' which do not match the API field names, leading to errors.
Environment
Additional Context
A similar issue affects
Get-NBContactAssignmentwith parameter Content_Type_Id.The wrong behaviour is not caught by module tests. There, the invalid API parameter is checked for presence.
IntegrationTests.ps1does not have tests for contact assignments.Possible Solution (optional)
I will provide a PR fixing the issue.