Using VRF object instead of id in POST to api/ipam/prefixes/<pk>/available-ips/ #1242

Closed
opened 2025-12-29 16:30:33 +01:00 by adam · 1 comment
Owner

Originally created by @alejandrosalinas on GitHub (Sep 18, 2017).

When posting on api/ipam/prefixes//available-ips/ the code uses the entire VRF object instead of the VRF ID on the serializer.

data = request.data.copy()
data['address'] = '{}/{}'.format(ipaddress, prefix.prefix.prefixlen)
data['vrf'] = prefix.vrf                                                  <=== HERE
serializer = serializers.WritableIPAddressSerializer(data=data)

which then fails with

"Incorrect type. Expected pk value, received VRF."

Originally created by @alejandrosalinas on GitHub (Sep 18, 2017). When posting on api/ipam/prefixes/<pk>/available-ips/ the code uses the entire VRF object instead of the VRF ID on the serializer. ``` data = request.data.copy() data['address'] = '{}/{}'.format(ipaddress, prefix.prefix.prefixlen) data['vrf'] = prefix.vrf <=== HERE serializer = serializers.WritableIPAddressSerializer(data=data) ``` which then fails with ```"Incorrect type. Expected pk value, received VRF."```
adam added the type: bug label 2025-12-29 16:30:33 +01:00
adam closed this issue 2025-12-29 16:30:33 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 18, 2017):

Thank you for the bug report, but in the future please be sure to use the issue template.

@jeremystretch commented on GitHub (Sep 18, 2017): Thank you for the bug report, but in the future please be sure to use [the issue template](https://github.com/digitalocean/netbox/blob/develop/.github/ISSUE_TEMPLATE.md).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1242