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

Updating of ConfigContexts via API fails when related objects are assigned #2301

Closed
prx-nvdm opened this issue Aug 3, 2018 · 3 comments
Closed
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@prx-nvdm
Copy link

prx-nvdm commented Aug 3, 2018

Environment

Python version: 3.5.2
NetBox version: last git version (33e45a2)

Steps to Reproduce

  1. Attempt to patch an existing ConfigContext via a PUT request to the API, with changes to one or more sites/tenants etc.
curl -X PUT \
-H "Authorization: Token <TOKEN>" \
-H "Content-Type: application/json" \
-H "Accept: application/json; indent=4" \
http://localhost:8000/api/extras/config-contexts/ \
--data '{"tenants":[83],"id":5,"name":"Tenant_ConfigContext","description":"Tenant_ConfigContext","weight":2000,"is_active":true,"data":{}}'

Expected Behavior

The given ConfigContext should be updated succesfully.

Observed Behavior

An exception is raised:
Direct assignment to the forward side of a many-to-many set is prohibited. Use tenants.set() instead.

@jeremystretch
Copy link
Member

You need to use the URL for the existing ConfigContext in your request:

http://localhost:8000/api/extras/config-contexts/5/

The endpoint without a primary key is used only for listing all ConfigContexts or creating a new one.

@jeremystretch jeremystretch added type: bug A confirmed report of unexpected behavior in the application status: accepted This issue has been accepted for implementation beta labels Aug 3, 2018
@jeremystretch
Copy link
Member

This stemmed from an error in ValidatedModelSerializer.

@prx-nvdm
Copy link
Author

prx-nvdm commented Aug 6, 2018

Thanks for the quick fix! @jeremystretch

@lock lock bot locked as resolved and limited conversation to collaborators Jan 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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

No branches or pull requests

2 participants