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

Unable to reference object id in site using REST API #16011

Closed
rodvand opened this issue May 7, 2024 · 2 comments · Fixed by #16013
Closed

Unable to reference object id in site using REST API #16011

rodvand opened this issue May 7, 2024 · 2 comments · Fixed by #16013
Assignees
Labels
severity: medium Results in substantial degraded or broken functionality for specfic workflows status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@rodvand
Copy link
Contributor

rodvand commented May 7, 2024

Deployment Type

Self-hosted

NetBox Version

v4.0.0

Python Version

3.10

Steps to Reproduce

  1. Create a tenant named "Test Tenant". Make a note of the tenant's id (in my case it's 7)
  2. Create a site using REST API
curl -s -X POST \
-H "Authorization: Token 0123456789abcdef0123456789abcdef01234567" \
-H "Content-Type: application/json" \
http://localhost:32768/api/dcim/sites/ \
--data '{"name": "Test site 1", "slug": "test-site-1", "tenant": 7}' | jq '.'

Expected Behavior

The site is created in and tenant is set to Test tenant.

Observed Behavior

{
  "tenant": {
    "non_field_errors": [
      "Invalid data. Expected a dictionary, but got int."
    ]
  }
}

The same API calls work as expected in NetBox 3.7.

@rodvand rodvand added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels May 7, 2024
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation severity: medium Results in substantial degraded or broken functionality for specfic workflows and removed status: needs triage This issue is awaiting triage by a maintainer labels May 7, 2024
@jeremystretch
Copy link
Member

I see the issue with SiteSerializer; we're not passing nested=True to TenantSerializer. Easy fix.

@rodvand have you come across this issue for any other models? A quick check suggests it affects only the site model, but I'll do a more thorough audit.

@rodvand
Copy link
Contributor Author

rodvand commented May 7, 2024

@rodvand have you come across this issue for any other models? A quick check suggests it affects only the site model, but I'll do a more thorough audit.

I'll update if I come by any more of this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
severity: medium Results in substantial degraded or broken functionality for specfic workflows 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