API GET for prefix lists a vrf option in the API #6255

Closed
opened 2025-12-29 19:38:33 +01:00 by adam · 2 comments
Owner

Originally created by @c-po on GitHub (Mar 24, 2022).

NetBox version

v3.1.9

Python version

3.9

Steps to Reproduce

Retrive data from the /ipam/prefixes API endpoint using the API explorer

API explorer lists both vrf name and vrf_id as options
image

Calling the API and using vrf does not work

https://netbox/api/ipam/prefixes/?contains=10.0.9.0%2F24&vrf=mu_dc_prod

Calling the API and using vrf_id instead works

https://netbox/api/ipam/prefixes/?contains=10.0.9.0%2F24&vrf_id=40

image

Expected Behavior

As the API explorer offers both an ID of the VRF and apparently the VRF name to be used while searching - the VRF name does not work.

image

Observed Behavior

Calling the API

curl -X GET "https://ipam.foo.net/api/ipam/prefixes/?contains=10.0.9.0%2F24&vrf=mu_dc_prod" -H  "accept: application/json" -H  "X-CSRFToken: foo"

Results in

HTTP 400 Bad Request
Allow: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "vrf": [
        "Select a valid choice. mu_dc_prod is not one of the available choices."
    ]
}

image

Originally created by @c-po on GitHub (Mar 24, 2022). ### NetBox version v3.1.9 ### Python version 3.9 ### Steps to Reproduce Retrive data from the /ipam/prefixes API endpoint using the API explorer API explorer lists both `vrf` name and `vrf_id` as options ![image](https://user-images.githubusercontent.com/25299219/159903549-f2202877-d3f3-4b9a-bd1c-640538a9e4ad.png) #### Calling the API and using `vrf` does not work https://netbox/api/ipam/prefixes/?contains=10.0.9.0%2F24&vrf=mu_dc_prod #### Calling the API and using `vrf_id` instead works https://netbox/api/ipam/prefixes/?contains=10.0.9.0%2F24&vrf_id=40 ![image](https://user-images.githubusercontent.com/25299219/159904249-ddfa6632-d151-44d5-8a96-2a6a78f49e6f.png) ### Expected Behavior As the API explorer offers both an ID of the VRF and apparently the VRF name to be used while searching - the VRF name does not work. ![image](https://user-images.githubusercontent.com/25299219/159903549-f2202877-d3f3-4b9a-bd1c-640538a9e4ad.png) ### Observed Behavior Calling the API ```bash curl -X GET "https://ipam.foo.net/api/ipam/prefixes/?contains=10.0.9.0%2F24&vrf=mu_dc_prod" -H "accept: application/json" -H "X-CSRFToken: foo" ``` Results in ``` HTTP 400 Bad Request Allow: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS Content-Type: application/json Vary: Accept { "vrf": [ "Select a valid choice. mu_dc_prod is not one of the available choices." ] } ``` ![image](https://user-images.githubusercontent.com/25299219/159903868-3c38ee7f-6630-49d4-8c42-1e57c1b3347f.png)
adam closed this issue 2025-12-29 19:38:33 +01:00
Author
Owner

@jeremystretch commented on GitHub (Mar 24, 2022):

The vrf filter matches on the VRF's route distinguisher (RD), not its name.

@jeremystretch commented on GitHub (Mar 24, 2022): The `vrf` filter matches on the VRF's route distinguisher (RD), not its name.
Author
Owner

@c-po commented on GitHub (Mar 24, 2022):

Thanks for the clarification

@c-po commented on GitHub (Mar 24, 2022): Thanks for the clarification
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6255