Closed mostdaysarebaddays closed 10 months ago
This is not a pynetbox issue, please open an issue in NetBox repo (if there isn't one already).
$ curl -X POST http://netbox-test.lein.io/api/ipam/vlan-groups/1/available-vlans/ -H "Content-type: application/json"
-H "Authorization: Token xxxxxxxx" -d '{"name":"Test222", "tenant": 1}' -s | jq .
{
"tenant": [
"Related objects must be referenced by numeric ID or by dictionary of attributes. Received an unrecognized value: TestTenant"
]
}
$ curl -X POST http://netbox-test.lein.io/api/ipam/vlan-groups/1/available-vlans/ -H "Content-type: application/json"
-H "Authorization: Token xxxxxxxx" -d '{"name":"Test222", "tenant": {"name": "TestTenant"}}' -s | jq .
{
"tenant": [
"Related objects must be referenced by numeric ID or by dictionary of attributes. Received an unrecognized value: TestTenant"
]
}
This issue can be closed.
pynetbox (or netbox, possibly) is converting IDs into plain text for trying to create a VLAN and it's causing issues.
Relevant code below:
_tenantname = input("Tenant?") tenants = nb.tenancy.tenants.get(name=tenantname) vlan_group = nb.ipam.vlan_groups.get(11) vlan_group.availablevlans.create({"name": vlantag+tenantname,"tenant":tenants.id,"role":"15"})
Output/error below showing the 'tenant' and 'role' have been converted to their name instead of the tenant.id and the hard coded role ID.
The request failed with code 400 Bad Request: {'tenant': ['Related objects must be referenced by numeric ID or by dictionary of attributes. Received an unrecognized value: LRLP'], 'role': ['Related objects must be referenced by numeric ID or by dictionary of attributes. Received an unrecognized value: External Cross Connects']}