You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2022-12-29 17:02:27

jmalone_lancium
Member
Registered: 2022-12-29
Posts: 2

Is it possible to add a Computer to a ticket using the API? SOLVED

Hello,

I'm trying to integrate our monitoring alert system with GLPI. I can easily create a new ticket using the API (either PHP or Python library). After that, I want to associate the affected computer(s) with the new ticket but I cannot find a way to add an item to a ticket using the API. Is there any documentation or examples showing how to update "Items" in Tickets using the API?

Thanks,

-Josh

Last edited by jmalone_lancium (2023-01-03 15:44:52)

Offline

#2 2023-01-03 15:14:34

cconard96
Moderator
Registered: 2018-07-31
Posts: 2,813
Website

Re: Is it possible to add a Computer to a ticket using the API? SOLVED

Can you try adding an "items_id" property to the input body? It should be an object where the keys are item types like "Computer" and the values are arrays of IDs for that item type.

Ex:

"items_id": {
   "Computer": [104, 202]
}


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

#3 2023-01-03 15:44:05

jmalone_lancium
Member
Registered: 2022-12-29
Posts: 2

Re: Is it possible to add a Computer to a ticket using the API? SOLVED

That did it! Thanks!

Python library usage:

item_id=sys.argv[1].rstrip()
t_data={
    'name': "Test ticket from API script",
    'content': "This is only a test.\n",
    'items_id': {
        'Computer': [item_id]
    }

}
print("Adding ticket with item %s..." % (item_id))
print(glpi.add('Ticket', t_data))

Offline

Board footer

Powered by FluxBB