You are not logged in.
Hey, guys. I'm trying to synchronize NetBox (new discovered servers appears first here) and GLPI using python module glpi_api.
When I'm trying to update computer like this:
parameters = {
'id': glpi_id,
'name': netbox_name,
'Manufacturer.name': netbox_manufacturer,
'ComputerModel.name': device_type,
'otherserial': netbox_inventory
}
glpi.update('Computer', parameters)
I'm getting response:
Error processing device with serial number : Object of type DeviceTypes is not JSON serializable
What am I doing wrong?
Offline
Seems like the data from netbox_inventory is not in a JSON format. You will have to JSON serialize it. Here is an example:
# import module
import json
# Data to be written
parameters = {
'id': glpi_id,
'name': netbox_name,
'Manufacturer.name': netbox_manufacturer,
'ComputerModel.name': device_type,
'otherserial': netbox_inventory
}
# Serializing json
res = json.dumps( parameters )
glpi.update('Computer', res)
You have to use json.dumps to convert it to JSON type.
Last edited by At0kir (2024-03-22 17:20:43)
Offline
Well, it is in json format.. if we print(parameters):
{'id': 2125, 'name': '3c:e1:a1:83:91:9b', 'Manufacturer.name': 'Lenovo', 'ComputerModel.name': HR650X, 'otherserial': 'SRV371753'}
upd: Ok, I got it. 'ComputerModel.name' - value should be string like this: 'ComputerModel.name': 'HR650X'. Solved)
Last edited by rocksteady (2024-03-22 19:18:39)
Offline