Multiobject custom field in site not getting ip address value #15863
-
Hi I am using pynetbox to save the IP Address in IPAM .I am trying to assign the IP address to custom field in site which is multiobject IP address object type.Although IPs are getting displayed under custom field but when I try to assign the IPs using pynetbox to custom field It is failing..' site = pynetbox.dcim.sites.get(name="site-name") netbox_ip = pynetbox.api.ipam.ip_addresses.create(address="ip_address", status="active", tenant=tenanat.id) Error:- 400 Bad request {'assigned_object_type': ["Invalid value".Specify a content type as '<app_label:<model_name>>']} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Also my goal is to assign IP address to custom fields for multiple sites via api which is multiobject IP adresss type.How can I achieve that efficiently as there are 600 sites. |
Beta Was this translation helpful? Give feedback.
-
That seems to be telling you to try But I didn't think you could assign an IP address directly to a site. I thought you had to assign it to an interface or vminterface. Also, the code you showed doesn't seem to do anything with custom fields. If you have created a custom field on IPAddress, then it would be something like
However, since you said you created a custom field on Site, then clearly you'd have to update the custom fields on the specific site of interest. I suggest you try making some object assignments within the GUI, and use pynetbox to query the site before and after, to see how the custom field data has changed. Here, for example, I have some custom fields set on Device:
You should be able to read/update custom fields on Site in a similar way. |
Beta Was this translation helpful? Give feedback.
I suspect you need to give a list of object IDs: i.e. first do a query to lookup IP address 10.4.128.160/27 and get its ID.