Primary key must be an integer error with API when use python requests

429 views
Skip to first unread message

Kienct

unread,
Aug 24, 2018, 6:55:49 AM8/24/18
to NetBox
Hi everyone,
I'm kinda new to Netbox and API. My goal is using API to assign interface to LAG. But when I'm using python requests, I able to modify some field of interface like mtu, description... but unable to modify nested field like lag, untagged_vlan,form_factor.
Result I get from this is {"lag":["Primary key must be an integer"]}. Same result for other nested field.
I feel like I made stupid mistake here. 
Netbox V2.4.3

api.PNG












Thank you.

Jeremy Stretch

unread,
Aug 24, 2018, 9:32:32 AM8/24/18
to Kienct, NetBox
You need to specify the device ID, not a dictionary with its name. For example:

"device": 123

--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to netbox-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/aae54b4a-bdc5-481a-9b80-e9eeda82dd60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Marc Heard

unread,
Aug 28, 2018, 10:07:43 AM8/28/18
to NetBox
when i try to update a circuit termination interface by id, it asks for a dictionary. And if i supply a dictionary with device: id and name: interface i get fields must make a unique set.


On Friday, August 24, 2018 at 8:32:32 AM UTC-5, Jeremy Stretch wrote:
You need to specify the device ID, not a dictionary with its name. For example:

"device": 123
On Fri, Aug 24, 2018 at 6:55 AM, Kienct <kie...@gmail.com> wrote:
Hi everyone,
I'm kinda new to Netbox and API. My goal is using API to assign interface to LAG. But when I'm using python requests, I able to modify some field of interface like mtu, description... but unable to modify nested field like lag, untagged_vlan,form_factor.
Result I get from this is {"lag":["Primary key must be an integer"]}. Same result for other nested field.
I feel like I made stupid mistake here. 
Netbox V2.4.3

api.PNG












Thank you.

--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
To post to this group, send email to netbox-...@googlegroups.com.

Heitor Moraes

unread,
Oct 12, 2018, 6:59:08 PM10/12/18
to NetBox
I'm stuck with the same problem.

If I supply a dictionary the error is "The fields device, name must make a unique set.", if I supply the interface id, the error is "Invalid data. Expected a dictionary, but got int.".
Reply all
Reply to author
Forward
0 new messages