"parent_device" property seems to be unseen by server at REST HTTP POST #11713
-
Dear community, I have problems with uploading DCIM configuration when I need to populate my already uploaded parent chassis device with child devices. My HTTP POST message is the following. I collected it with TCP Dump.
The following is the server reply. Also captured with tcpdump.
We see that almost all introduced properties had been successfully accepted and processed. Only property "parent_device" was somehow ignored. I tried to send data of any type under "parent_device" but there was no reaction from the server. Even no error message. As if this property does not exist at all on server. In web console I can see the created module on the correct site and in the correct rack so it it can be manually installed to the parent device "device-bay". But this does not go right with API. What do I do wrong? It seems to be an obvious scenario. When I use modules instead I successfully install modules in module-bays of parent device. But modules do not allow the same port name on different modules on one device. So I use child devices. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Thats because netbox/netbox/dcim/api/serializers.py Lines 663 to 672 in 19da92b I don't think it was ever intended to get written to however. You need to find the |
Beta Was this translation helpful? Give feedback.
-
The format used to POST/PUT/PATCH data isn't the same as data is returned, eg foreign key fields are often returned with details like name, id, display, url, etc. but are written as just the id number, eg installedDevice: 1234. or sometimes they are updated on a different data model entirely, eg. IP Address is associated with Interface on the IP Address model not the Interface model, but is available on Interface and Device. Take a look at the Swagger/OpenAPI docs to see what the field names and expected values are for the field you are trying to update.
—
Mark Tinberg ***@***.***>
Division of Information Technology-Network Services
University of Wisconsin-Madison
…________________________________
From: Viktor Patrukhachev ***@***.***>
Sent: Friday, February 10, 2023 3:06 AM
To: netbox-community/netbox ***@***.***>
Cc: Subscribed ***@***.***>
Subject: Re: [netbox-community/netbox] "parent_device" property seems to be unseen by server at REST HTTP POST (Discussion #11713)
@jsenecal<https://github.com/jsenecal> Thank you for assistance. I tried your recommendation. It passed without errors but still without the required effect.
PUT /api/dcim/device-bays/ HTTP/1.1
Host: 192.168.105.5
Authorization: Token b8ef4c32408b225a22f924fb7939634f93c3c6c6
Transfer-Encoding: chunked
traceparent: 00-3f3b152d5c173227b9826c5002ff5949-d77b02c06e59a02f-00
Content-Type: application/json; charset=utf-8
[
{
"id": 128,
"name": "Bay-1",
"device": 330,
"installedDevice": {
"id": 331
}
}
]
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Fri, 10 Feb 2023 08:54:54 GMT
Content-Type: application/json
Content-Length: 410
Connection: keep-alive
Vary: Accept, Cookie, Origin
Allow: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
API-Version: 3.2
X-Content-Type-Options: nosniff
Referrer-Policy: same-origin
Cross-Origin-Opener-Policy: same-origin
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=31536000; includeSubDomains
[
{
"id": 128,
"url": "http://netbox.example.com/api/dcim/device-bays/128/",
"display": "Bay-1",
"device": {
"id": 330,
"url": "http://netbox.example.com/api/dcim/devices/330/",
"display": "QPL-WEM-1",
"name": "QPL-WEM-1"
},
"name": "Bay-1",
"label": "",
"description": "",
"installed_device": null,
"tags": [],
"custom_fields": {},
"created": "2023-02-10T08:54:53.866019Z",
"last_updated": "2023-02-10T08:54:54.189061Z"
}
]
There is ""installed_device": null" in the reply. Probably "installed_device" is also a read-only property. So we need to search further.
—
Reply to this email directly, view it on GitHub<#11713 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAS7UM6SGQJ2SK3NJJQDUHLWWYALBANCNFSM6AAAAAAUWPB75U>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
Thats because
parent_device
is a nested serializer:netbox/netbox/dcim/api/serializers.py
Lines 663 to 672 in 19da92b
I don't think it was ever intended to get written to however.
You need to find the
device_bay
id and then …