You are not logged in.
Pages: 1
I'm trying to update my computer's position in rack (change rack/unit). This is my request:
curl -s -L -X PATCH 'http://devglpi1z1.mydomain.net/apirest.php/computer/466' \
-H 'Content-Type: application/json' \
-H 'App-Token: 7Ja9hnKdzABCL7qAi1CSwyDCDarb2gFGqgZfLVL' \
-H 'Session-Token: 8c0d0346bf9a0db3569c23b59cbe62d' \
-d '{
"input": {
"180": "6H8070",
"181": 12
}
}'
It says:
[
{
"466": true,
"message": ""
}
]
But nothing happens, and computer's position is not updated. What is wrong?
Offline
Search options:
"180": {
"name": "Name",
"table": "glpi_racks",
"field": "name",
"datatype": "dropdown",
"nosearch": false,
"nodisplay": false,
"available_searchtypes": [
"contains",
"notcontains",
"equals",
"notequals"
],
"uid": "Computer.Item_Rack.Rack.name"
},
"181": {
"name": "Position",
"table": "glpi_items_racks",
"field": "position",
"datatype": "number",
"nosearch": false,
"nodisplay": false,
"available_searchtypes": [
"contains",
"notcontains"
],
"uid": "Computer.Item_Rack.position"
},
I'm not quite understand what json payload should I send to glpi api to update these fields...
Offline
{
"input": {
"id": 466,
"otherserial": "SRV348432",
"Item_Rack.Rack.name": "6H8J070",
"Item_Rack.position": 12
}
}
This payload does not work also. It changes only 'otherserial' field.
Offline
Updates are not done with search options. If you want to update Item_Rack data, you need to do that for the Item_Rack resource, not the computer.
PATCH 'apirest.php/Item_Rack/ITEM_RACK_ID'
{
"input": {
"id": ITEM_RACK_ID,
"position": 12
}
}
GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.
Offline
Thanks. This works for servers in racks. But how do I get item_id for servers, that are not in racks yet? I have a bunch of servers that I need to put into racks, how do I do it?
P.S. Is there any document that describe how to work with racks via api?
Last edited by rocksteady (2024-12-13 14:54:57)
Offline
I need to do something like this:
curl -s -L -X PUT 'http://devglpi1z1.mydomain.net/apirest.php/rack/Item_Rack?get_hateoas=false' \
-H 'Content-Type: application/json' \
-H 'App-Token: 7Ja9hnKdzABCL7qAi1CNSwyDCDarb2gFGqgZfLVL' \
-H 'Session-Token: c11cec4e0aeaf067b445e1db3c8782cf' \
-d '{
"input": {
"id": 93, #Rack ID
"items_id": 466, #Computer ID
"position": 40,
"orientation": 0,
"bgcolor": "#69ceba",
"hpos": 0,
"is_reserved": 0
}
}'
But it doesn't work...
Last edited by rocksteady (2024-12-13 15:30:38)
Offline
Pages: 1