Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Choices are not returned when the API token can PUT but not POST on an endpoint #591

Open
BenoitKnecht opened this issue Nov 3, 2023 · 5 comments · May be fixed by #592
Open

Choices are not returned when the API token can PUT but not POST on an endpoint #591

BenoitKnecht opened this issue Nov 3, 2023 · 5 comments · May be fixed by #592
Assignees
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@BenoitKnecht
Copy link

pynetbox version

v7.1.0

NetBox version

v3.4.3

Python version

3.9

Steps to Reproduce

Using an API token that cannot POST on the /dcim/devices/ endpoint for instance, try getting choices using

nb.dcim.devices.choices()

Expected Behavior

A list of choices is returned.

Observed Behavior

ValueError: Unexpected format in the OPTIONS response at https://netbox.example.com/api/dcim/devices
@BenoitKnecht BenoitKnecht added the type: bug A confirmed report of unexpected behavior in the application label Nov 3, 2023
@BenoitKnecht
Copy link
Author

I can submit a PR for a simple fix that would get the choices from the .actions.PUT sections returned by the OPTIONS request when .actions.POST is missing.

@abhi1693 abhi1693 added the status: accepted This issue has been accepted for implementation label Nov 4, 2023
@markkuleinio
Copy link
Contributor

Just wondering: what is the use case for fetching the choices list when there is no possibility anyway to use the choice values to create/edit objects?

Or do I miss something about POST vs PUT

@BenoitKnecht
Copy link
Author

Just wondering: what is the use case for fetching the choices list when there is no possibility anyway to use the choice values to create/edit objects?

Or do I miss something about POST vs PUT

@markkuleinio With POST you create new objects, and with PUT you update existing objects. So fetching choices is useful in that latter case too. 🙂

@markkuleinio
Copy link
Contributor

Right, so the use case is a user that doesn't have create access but has modify access.

@BenoitKnecht
Copy link
Author

Hey, could someone review (and ideally merge) the PR above (#592)? I'm still hitting this bug whenever I use Ansible to interact with Netbox.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants