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 2019-09-13 16:22:07

mecmav
Member
From: Brasil
Registered: 2019-03-22
Posts: 326

GLPI-API - Créer un appel dans GLPI via Zabbix

J'ai un problème que je dois résoudre pour fournir un système de production glpi à une entreprise.

Actuellement, la société a un glpi de 0,90, mais est très ancienne et incomplète. Il existe une intégration avec un serveur Zabbix qui surveille les hôtes (passerelles) à partir de divers emplacements et lors de la détection d’une panne, ouvre un appel automatique sur GLPI. Lorsque zabbix détecte que ce bogue a été corrigé, l'appel est immédiatement fermé automatiquement. J'ai vérifié que le plug-in webservices ouvre automatiquement les appels avec un utilisateur zabbix ajouté à la base de données GLPI.

J'ai effectué des recherches à ce sujet et découvert qu'à partir de la version 9.1 de GLPI, l'API native existe déjà. GLPI 9.4.2 ne prend pas en charge le plug-in webservices (qui est compatible jusqu’à la version 9.3).

Je crois que cette intégration doit se faire via l’API, afin que zabbix puisse ouvrir des appels automatiques dans GLPI.

Je ne sais pas par où commencer, j'ai fait beaucoup de recherches, mais peu de sujets expliquent ce paramètre.

J'ai besoin de livrer ce projet bientôt, il est nécessaire d'automatiser l'ouverture et la fermeture des appels via Zabbix.

Des suggestions par où commencer ??

Toute aide sera la bienvenue et merci d'avance.

Offline

#2 2019-09-15 16:25:51

mecmav
Member
From: Brasil
Registered: 2019-03-22
Posts: 326

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

Anyone that know about it can help me ?
Need some urgent help

Offline

#3 2019-09-15 16:33:36

Isia
Member
Registered: 2019-05-26
Posts: 96

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

Salut,

tu peux le faire via l'api avec la version 9.4.2. Le seul changement interviendra dans le faite que tu dois toi même coder la relation avec Zabbix et l'api de GLPI (Chose que faisait le plugin webservices) mais 2 requêtes suffisent il me semble pour ton cas. Si tu veux plus de précision, hésite pas.

Last edited by Isia (2019-09-15 16:35:33)

Offline

#4 2019-09-15 22:15:04

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 6,168

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

1) vous devez activer l'API dans GLPI puis creer une client correspondant à l'IP de zabbix.
2) creez un utilisateur ZABBIX dans GLPI et initiez son jeton d'api

pour ouvrir un ticket :

1) ouvvrez une session pour l'utilisateur ZABBIX :   curl -X GET \
-H 'Content-Type: application/json' \
-H "Authorization: user_token {MONTOKEN}" \
-H "App-Token: MONAPPTOKEN" \
'http://MONSERVEUR/glpi/apirest.php/initSession'

vous allez ensuite récupérer un session_token pour votre utilisateur zabbix


ensuite

creez le ticket avec la methode POST et le JSON suivant  :
curl -X POST\
-H 'Content-Type: application/json' \
-H "Sess-Token {MONTOKEN}" \
-H "App-Token: MONAPPTOKEN" \
-d {"input": {"name": "Ticket Name", "content": "Ticket Desc","status":"1","urgency":"1","_disablenotif":true}}'http://MONSERVEUR/glpi/apirest.php/Ticket/'

puis enuite
un kill session.


Trouver la panne avant de réparer...
GLPI10.0.10 (ubuntu 22.04 PHP8.1  Mariadb10.6 ) plugins : comportements 2.7.2 reports 1.16.0 formcreator 2.13.8, datainjection 2.13.4 fields 1.21.6

Offline

#5 2019-09-16 07:30:03

Isia
Member
Registered: 2019-05-26
Posts: 96

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

Hello @LaDenrée, je rebondi sur ton post smile
J'ai 2 questions par rapport à ton explication, pourquoi killer la session, du moins ça fait quoi si on ne le fait pas ? et à quoi correspond le paramètre "_disablenotif":true" ? à l’envoi de mail ?
Merci .

Offline

#6 2019-09-16 08:34:43

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 6,168

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

c'est toujours plus propre de fermer les sessions.

pour le disable notif, je ne l'utilise pas ( j'ai récupéré le bout de code sans le nettoyer) il n'est pas obligatoire.

ci dessous la liste des champs des tickets par API, certains n'ont pas de sens pour la creation, ou sont complétés par GLPI ( j'ai commenté les lignes)

    "input": {
        "entities_id": "1",
        "name": "    ",
      //  "date": "2016-10-06 17:34:28",
       // "closedate": "2016-10-15 14:50:02",
      //  "solvedate": "2016-10-08 10:32:47",
      //  "date_mod": "2016-10-15 14:50:02",
       // "users_id_lastupdater": "6",
       // "status": "6",
        "users_id_recipient": "9",
        "requesttypes_id": "2",
        "content": "description",
        "urgency": "3",
        "impact": "3",
        "priority": "3",
        "itilcategories_id": "1",
        "type": "2",

        "global_validation": "1",
        "slts_ttr_id": "0",
        "slts_tto_id": "0",
        "ttr_slalevels_id": "0",
        "_users_id_requester": "'.$id_demandeur.'"
       
//        "begin_waiting_date": "2016-10-08 10:32:47",
  //      "sla_waiting_duration": "0",
//       "waiting_duration": "142673",
  //      "close_delay_stat": "625061",
  //      "solve_delay_stat": "4826",
  //      "takeintoaccount_delay_stat": "934",
   //     "actiontime": "0",
        "is_deleted": "0",
        "locations_id": "1",
     //   "validation_percent": "0"       
    }
}';


Trouver la panne avant de réparer...
GLPI10.0.10 (ubuntu 22.04 PHP8.1  Mariadb10.6 ) plugins : comportements 2.7.2 reports 1.16.0 formcreator 2.13.8, datainjection 2.13.4 fields 1.21.6

Offline

#7 2019-09-16 13:47:04

mecmav
Member
From: Brasil
Registered: 2019-03-22
Posts: 326

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

Isia wrote:

Salut,

tu peux le faire via l'api avec la version 9.4.2. Le seul changement interviendra dans le faite que tu dois toi même coder la relation avec Zabbix et l'api de GLPI (Chose que faisait le plugin webservices) mais 2 requêtes suffisent il me semble pour ton cas. Si tu veux plus de précision, hésite pas.


Merci pour votre réponse maintenant.

Je suis désolé s'il est difficile de me comprendre, j'utilise Google Translator

J'ai même pensé que cela ne devrait fonctionner que via l'API.

Le plugin webservices fonctionne-t-il jusqu'à la version 9.3?

Avez-vous des conseils pour commencer la relation entre zabbix et l’API GLPI?

Last edited by mecmav (2019-09-16 14:06:48)

Offline

#8 2019-09-16 13:59:39

mecmav
Member
From: Brasil
Registered: 2019-03-22
Posts: 326

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

LaDenrée wrote:

1) vous devez activer l'API dans GLPI puis creer une client correspondant à l'IP de zabbix.
2) creez un utilisateur ZABBIX dans GLPI et initiez son jeton d'api

pour ouvrir un ticket :

1) ouvvrez une session pour l'utilisateur ZABBIX :   curl -X GET \
-H 'Content-Type: application/json' \
-H "Authorization: user_token {MONTOKEN}" \
-H "App-Token: MONAPPTOKEN" \
'http://MONSERVEUR/glpi/apirest.php/initSession'

vous allez ensuite récupérer un session_token pour votre utilisateur zabbix


ensuite

creez le ticket avec la methode POST et le JSON suivant  :
curl -X POST\
-H 'Content-Type: application/json' \
-H "Sess-Token {MONTOKEN}" \
-H "App-Token: MONAPPTOKEN" \
-d {"input": {"name": "Ticket Name", "content": "Ticket Desc","status":"1","urgency":"1","_disablenotif":true}}'http://MONSERVEUR/glpi/apirest.php/Ticket/'

puis enuite
un kill session.


Reconnaissant pour votre réponse, vraiment reconnaissant

J'ai compris. Je sais de cette partie que je dois ajouter l'adresse IP du client qui permettra d'accéder à l'API GLPI.

comme je l'ai mentionné au début de cet article, la version qui fonctionne (à 0,90) contient le plugin webservices et une règle de gestion pour les appels ouverts, c'est-à-dire lorsque l'appel provient de la source de la requête "webservices" et que l'utilisateur est " zabbix "affecte le groupe N3, affecte l'observateur X et le technicien Y.

En effectuant ces mêmes procédures via l’API, devriez-vous obtenir les user_token, app_token et session_token de l’utilisateur zabbix?

après avoir obtenu session_token, puis-je exécuter les codes que vous m'avez informés?

ce code devrais-je tester avec postman ??? ou devrais-je utiliser la ligne de commande linux de mon glpi?

Last edited by mecmav (2019-09-16 14:07:30)

Offline

#9 2019-09-16 14:02:23

mecmav
Member
From: Brasil
Registered: 2019-03-22
Posts: 326

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

Isia wrote:

Hello @LaDenrée, je rebondi sur ton post smile
J'ai 2 questions par rapport à ton explication, pourquoi killer la session, du moins ça fait quoi si on ne le fait pas ? et à quoi correspond le paramètre "_disablenotif":true" ? à l’envoi de mail ?
Merci .


Je pense que cela désactive l'envoi d'une notification aux utilisateurs impliqués dans l'appel, que ce soit une notification par courrier électronique, télégramme quelconque

C’est une bonne question et elle peut aider, moi et d’autres également, lorsque cette méthode d’ouverture d’appel zabbix dans glpi commence à fonctionner.

Offline

#10 2019-09-16 14:05:05

mecmav
Member
From: Brasil
Registered: 2019-03-22
Posts: 326

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

LaDenrée wrote:

c'est toujours plus propre de fermer les sessions.

pour le disable notif, je ne l'utilise pas ( j'ai récupéré le bout de code sans le nettoyer) il n'est pas obligatoire.

ci dessous la liste des champs des tickets par API, certains n'ont pas de sens pour la creation, ou sont complétés par GLPI ( j'ai commenté les lignes)

    "input": {
        "entities_id": "1",
        "name": "    ",
      //  "date": "2016-10-06 17:34:28",
       // "closedate": "2016-10-15 14:50:02",
      //  "solvedate": "2016-10-08 10:32:47",
      //  "date_mod": "2016-10-15 14:50:02",
       // "users_id_lastupdater": "6",
       // "status": "6",
        "users_id_recipient": "9",
        "requesttypes_id": "2",
        "content": "description",
        "urgency": "3",
        "impact": "3",
        "priority": "3",
        "itilcategories_id": "1",
        "type": "2",

        "global_validation": "1",
        "slts_ttr_id": "0",
        "slts_tto_id": "0",
        "ttr_slalevels_id": "0",
        "_users_id_requester": "'.$id_demandeur.'"
       
//        "begin_waiting_date": "2016-10-08 10:32:47",
  //      "sla_waiting_duration": "0",
//       "waiting_duration": "142673",
  //      "close_delay_stat": "625061",
  //      "solve_delay_stat": "4826",
  //      "takeintoaccount_delay_stat": "934",
   //     "actiontime": "0",
        "is_deleted": "0",
        "locations_id": "1",
     //   "validation_percent": "0"       
    }
}';





chaque appel ouvert doit-il ouvrir une nouvelle session?

après l'ouverture de l'appel, la session est-elle fermée ou la session n'est-elle fermée que lorsque l'appel est terminé (résolu / fermé)?

Ce modèle de code est-il le même pour ouvrir un appel?

Offline

#11 2019-09-16 14:18:12

mecmav
Member
From: Brasil
Registered: 2019-03-22
Posts: 326

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

LaDenrée wrote:

1) vous devez activer l'API dans GLPI puis creer une client correspondant à l'IP de zabbix.

2) creez un utilisateur ZABBIX dans GLPI et initiez son jeton d'api

Dans cette partie, dois-je ajouter un utilisateur manuellement dans glpi (par exemple, zabbix)?
Cet utilisateur doit-il avoir les privilèges de superutilisateur sur GLPI?
Cet utilisateur doit-il être identique à l'administrateur sur zabbix?

désolé pour mes doutes débutants, c’est que certains doutes se font jour.

Offline

#12 2019-09-16 16:08:24

mecmav
Member
From: Brasil
Registered: 2019-03-22
Posts: 326

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

mecmav wrote:
LaDenrée wrote:

1) vous devez activer l'API dans GLPI puis creer une client correspondant à l'IP de zabbix.
2) creez un utilisateur ZABBIX dans GLPI et initiez son jeton d'api

pour ouvrir un ticket :

1) ouvvrez une session pour l'utilisateur ZABBIX :   curl -X GET \
-H 'Content-Type: application/json' \
-H "Authorization: user_token {MONTOKEN}" \
-H "App-Token: MONAPPTOKEN" \
'http://MONSERVEUR/glpi/apirest.php/initSession'

vous allez ensuite récupérer un session_token pour votre utilisateur zabbix


ensuite

creez le ticket avec la methode POST et le JSON suivant  :
curl -X POST\
-H 'Content-Type: application/json' \
-H "Sess-Token {MONTOKEN}" \
-H "App-Token: MONAPPTOKEN" \
-d {"input": {"name": "Ticket Name", "content": "Ticket Desc","status":"1","urgency":"1","_disablenotif":true}}'http://MONSERVEUR/glpi/apirest.php/Ticket/'

puis enuite
un kill session.


Reconnaissant pour votre réponse, vraiment reconnaissant

J'ai compris. Je sais de cette partie que je dois ajouter l'adresse IP du client qui permettra d'accéder à l'API GLPI.

comme je l'ai mentionné au début de cet article, la version qui fonctionne (à 0,90) contient le plugin webservices et une règle de gestion pour les appels ouverts, c'est-à-dire lorsque l'appel provient de la source de la requête "webservices" et que l'utilisateur est " zabbix "affecte le groupe N3, affecte l'observateur X et le technicien Y.

En effectuant ces mêmes procédures via l’API, devriez-vous obtenir les user_token, app_token et session_token de l’utilisateur zabbix?

après avoir obtenu session_token, puis-je exécuter les codes que vous m'avez informés?

ce code devrais-je tester avec postman ??? ou devrais-je utiliser la ligne de commande linux de mon glpi?


I'm trying do what you say, but i'm getting this error:
I've already change session_token and app_token, i've get session_token normally. "[
    "ERROR_JSON_PAYLOAD_INVALID",
    "JSON payload seems not valid"
]"

Last edited by mecmav (2019-09-16 16:09:06)

Offline

#13 2019-09-16 16:52:20

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 6,168

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

@mecmav :
responding to post #11

Dans cette partie, dois-je ajouter un utilisateur manuellement dans glpi (par exemple, zabbix)?  oui


Cet utilisateur doit-il avoir les privilèges de superutilisateur sur GLPI? NON,  il faut  un profil P_ZABBIX qui peut créer, lire, attribuer les tickets.   



Cet utilisateur doit-il être identique à l'administrateur sur zabbix?  NON.


Trouver la panne avant de réparer...
GLPI10.0.10 (ubuntu 22.04 PHP8.1  Mariadb10.6 ) plugins : comportements 2.7.2 reports 1.16.0 formcreator 2.13.8, datainjection 2.13.4 fields 1.21.6

Offline

#14 2019-09-16 16:56:56

mecmav
Member
From: Brasil
Registered: 2019-03-22
Posts: 326

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

LaDenrée wrote:

@mecmav :
responding to post #11

Dans cette partie, dois-je ajouter un utilisateur manuellement dans glpi (par exemple, zabbix)?  oui


Cet utilisateur doit-il avoir les privilèges de superutilisateur sur GLPI? NON,  il faut  un profil P_ZABBIX qui peut créer, lire, attribuer les tickets.   



Cet utilisateur doit-il être identique à l'administrateur sur zabbix?  NON.

le profil technicien est pour ça

j'essaie d'ouvrir l'appel par api mais j'obtiens une erreur json_payload_invalid

Offline

#15 2019-09-16 17:14:01

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 6,168

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

I'm trying do what you say, but i'm getting this error:
I've already change session_token and app_token,

i've get session_token normally

I understand that Initsession works. Am I Right ?


then, can you GET an existing ticket in GUI Glpi ?
-login glpi with U_Zabbix user,
-set default  profile to P_ZABBIX 
- check for a ticket in glpi GUI that U_Zabbix is allowed to see . (remember ticket_id)

try to get it with API


curl -X GET\
-H 'Content-Type: application/json' \
-H "Sess-Token {MySessToken}" \
-H "App-Token: MONAPPTOKEN" \
'http://MONSERVEUR/glpi/apirest.php/Ticket/[ticket_id]/'

you should get your ticket.

I use PHP  but you can use Postman i'm not famliar with postman … :-(


Trouver la panne avant de réparer...
GLPI10.0.10 (ubuntu 22.04 PHP8.1  Mariadb10.6 ) plugins : comportements 2.7.2 reports 1.16.0 formcreator 2.13.8, datainjection 2.13.4 fields 1.21.6

Offline

#16 2019-09-16 17:45:11

mecmav
Member
From: Brasil
Registered: 2019-03-22
Posts: 326

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

LaDenrée wrote:

I'm trying do what you say, but i'm getting this error:
I've already change session_token and app_token,

i've get session_token normally

I understand that Initsession works. Am I Right ?


then, can you GET an existing ticket in GUI Glpi ?
-login glpi with U_Zabbix user,
-set default  profile to P_ZABBIX 
- check for a ticket in glpi GUI that U_Zabbix is allowed to see . (remember ticket_id)

try to get it with API


curl -X GET\
-H 'Content-Type: application/json' \
-H "Sess-Token {MySessToken}" \
-H "App-Token: MONAPPTOKEN" \
'http://MONSERVEUR/glpi/apirest.php/Ticket/[ticket_id]/'

you should get your ticket.

I use PHP  but you can use Postman i'm not famliar with postman … :-(

yes , initSession working and I have a session_token

now, I just created a test ticket and done. his id is 85, but dont filled all fields, because I inserted only name and content, like you say.

so I run this command to fetch a ticket, the id is 84: 10.9.23.252/apirest.php/Ticket/84.
the result is as follows:

{
    "id": 84,
    "entities_id": 0,
    "name": "Local X - Software não funciona, equipamento a0003",
    "date": "2019-09-05 22:32:37",
    "closedate": null,
    "solvedate": null,
    "date_mod": "2019-09-05 22:32:37",
    "users_id_lastupdater": 2,
    "status": 2,
    "users_id_recipient": 2,
    "requesttypes_id": 1,
    "content": "<p>usa</p>",
    "urgency": 3,
    "impact": 4,
    "priority": 3,
    "itilcategories_id": 28,
    "type": 1,
    "global_validation": 1,
    "slas_id_ttr": 18,
    "slas_id_tto": 0,
    "slalevels_id_ttr": 0,
    "time_to_resolve": "2019-09-06 15:30:00",
    "time_to_own": null,
    "begin_waiting_date": null,
    "sla_waiting_duration": 0,
    "ola_waiting_duration": 0,
    "olas_id_tto": 0,
    "olas_id_ttr": 0,
    "olalevels_id_ttr": 0,
    "internal_time_to_resolve": null,
    "internal_time_to_own": null,
    "waiting_duration": 0,
    "close_delay_stat": 0,
    "solve_delay_stat": 0,
    "takeintoaccount_delay_stat": 1,
    "actiontime": 0,
    "is_deleted": 0,
    "locations_id": 110,
    "validation_percent": 0,
    "date_creation": "2019-09-05 22:32:37",
    "links": [
        {
            "rel": "Entity",
            "href": "http://10.9.23.252/apirest.php/Entity/0"
        },
        {
            "rel": "User",
            "href": "http://10.9.23.252/apirest.php/User/2"
        },
        {
            "rel": "User",
            "href": "http://10.9.23.252/apirest.php/User/2"
        },
        {
            "rel": "RequestType",
            "href": "http://10.9.23.252/apirest.php/RequestType/1"
        },
        {
            "rel": "ITILCategory",
            "href": "http://10.9.23.252/apirest.php/ITILCategory/28"
        },
        {
            "rel": "SLA",
            "href": "http://10.9.23.252/apirest.php/SLA/18"
        },
        {
            "rel": "Location",
            "href": "http://10.9.23.252/apirest.php/Location/110"
        },
        {
            "rel": "Document_Item",
            "href": "http://10.9.23.252/apirest.php/Ticket/84/Document_Item/"
        },
        {
            "rel": "TicketTask",
            "href": "http://10.9.23.252/apirest.php/Ticket/84/TicketTask/"
        },
        {
            "rel": "TicketValidation",
            "href": "http://10.9.23.252/apirest.php/Ticket/8 … alidation/"
        },
        {
            "rel": "TicketCost",
            "href": "http://10.9.23.252/apirest.php/Ticket/84/TicketCost/"
        },
        {
            "rel": "Problem_Ticket",
            "href": "http://10.9.23.252/apirest.php/Ticket/8 … em_Ticket/"
        },
        {
            "rel": "Change_Ticket",
            "href": "http://10.9.23.252/apirest.php/Ticket/84/Change_Ticket/"
        },
        {
            "rel": "Item_Ticket",
            "href": "http://10.9.23.252/apirest.php/Ticket/84/Item_Ticket/"
        },
        {
            "rel": "ITILSolution",
            "href": "http://10.9.23.252/apirest.php/Ticket/84/ITILSolution/"
        },
        {
            "rel": "ITILFollowup",
            "href": "http://10.9.23.252/apirest.php/Ticket/84/ITILFollowup/"
        }
    ]
}


is this right??
case yes, i think half already worked.

Offline

#17 2019-09-16 18:14:08

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 6,168

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

this is the expected answer !

now lets try to create a ticket :  ( method POST)

curl -X POST \
-H 'Content-Type: application/json' \
-H "Session-Token: $SESSION_TOKEN" \
-H "App-Token: $APP_TOKEN" \
-d '{    "Input": {"entities_id": 0,    "name": "Local X - Software não funciona, equipamento a0003- by API","requesttypes_id": 1,\
"content": "ticket created by API","urgency": 3,"impact": 4,"priority": 3,"itilcategories_id": 28,"type": 1,    "slas_id_ttr": 18,    "locations_id": 110    }}' \
" 10.9.23.252/apirest.php/Ticket/"


( single quotes where missing before and after json in post #12  : sorry for that)


Trouver la panne avant de réparer...
GLPI10.0.10 (ubuntu 22.04 PHP8.1  Mariadb10.6 ) plugins : comportements 2.7.2 reports 1.16.0 formcreator 2.13.8, datainjection 2.13.4 fields 1.21.6

Offline

#18 2019-09-16 21:09:18

mecmav
Member
From: Brasil
Registered: 2019-03-22
Posts: 326

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

LaDenrée wrote:

this is the expected answer !

now lets try to create a ticket :  ( method POST)

curl -X POST \
-H 'Content-Type: application/json' \
-H "Session-Token: $SESSION_TOKEN" \
-H "App-Token: $APP_TOKEN" \
-d '{    "Input": {"entities_id": 0,    "name": "Local X - Software não funciona, equipamento a0003- by API","requesttypes_id": 1,\
"content": "ticket created by API","urgency": 3,"impact": 4,"priority": 3,"itilcategories_id": 28,"type": 1,    "slas_id_ttr": 18,    "locations_id": 110    }}' \
" 10.9.23.252/apirest.php/Ticket/"


( single quotes where missing before and after json in post #12  : sorry for that)


No need to apologize, you're helping me a lot

How should i use the full command ??? Is this for the Linux command line? "curl -X POST \
-H 'Content-Type: application / json' \
-H "Session-Token: $ SESSION_TOKEN" \
-H "App-Token: $ APP_TOKEN" \
-d '{"Input": {"entities_id": 0, "name": "Local X - Software does not work, a0003- by API equipment", "requesttypes_id": 1, \
"content": "ticket created by API", "urgency": 3, "impact": 4, "priority": 3, "itilcategories_id": 28, "type": 1, "slas_id_ttr": 18, "locations_id" : 110}} '\
"10.9.23.252/apirest.php/Ticket/"

when i use this way in postman i get the message from json_payload_invalid

works on postman only when I enter as follows: " Input ": {" entities_id ": 0," name ":" Local X - Software does not work, a0003- by API equipment "," requesttypes_id ": 1, \
"content": "ticket created by API", "urgency": 3, "impact": 4, "priority": 3, "itilcategories_id": 28, "type": 1, "slas_id_ttr": 18, "locations_id" : 110}}

A 500 error is issued, but the ticket is created in GLPI.

Offline

#19 2019-09-16 22:06:22

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 6,168

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

json end with 2 "}"    only one is open at the beginning.
this can lead to error 500.

when you create ticket by API, GLPI should return a JSON containing  ticket ID .

then you can add actors ( technicians, observers, groups, assigned groups)   or use business rules to assign tickets.


with api you can also add  folowups, tasks and solution (  solve tickets)


Trouver la panne avant de réparer...
GLPI10.0.10 (ubuntu 22.04 PHP8.1  Mariadb10.6 ) plugins : comportements 2.7.2 reports 1.16.0 formcreator 2.13.8, datainjection 2.13.4 fields 1.21.6

Offline

#20 2019-09-16 23:56:59

mecmav
Member
From: Brasil
Registered: 2019-03-22
Posts: 326

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

LaDenrée wrote:

json end with 2 "}"    only one is open at the beginning.
this can lead to error 500.

when you create ticket by API, GLPI should return a JSON containing  ticket ID .

then you can add actors ( technicians, observers, groups, assigned groups)   or use business rules to assign tickets.


with api you can also add  folowups, tasks and solution (  solve tickets)


Now I can understand by your explanation, I can up insert a JSON object and creates an ticket on glpi. Thanks by your patience and extreme collaborating.

about to ticket and assets rules I have some rules configured to manage and change the forwarding to expected users and groups. Can i Create a new ticket category and ticket model named "example" and create rules to assign to them. would it be the same way??

But, for example, for the API do I need to know beforehand the values of the data to enter for the respective categories, locations ??

Last edited by mecmav (2019-09-16 23:59:27)

Offline

#21 2019-09-17 00:21:58

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 6,168

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

if you want to create a ticket with locations, category  then you have to know locations_id , itilcategories_id,....

business rules applies to tickets whatever created by API or GUI. you can set technicians and goups by this way .   OR https://forum.glpi-project.org/viewtopic.php?id=158163


Trouver la panne avant de réparer...
GLPI10.0.10 (ubuntu 22.04 PHP8.1  Mariadb10.6 ) plugins : comportements 2.7.2 reports 1.16.0 formcreator 2.13.8, datainjection 2.13.4 fields 1.21.6

Offline

#22 2019-09-17 00:53:51

mecmav
Member
From: Brasil
Registered: 2019-03-22
Posts: 326

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

LaDenrée wrote:

if you want to create a ticket with locations, category  then you have to know locations_id , itilcategories_id,....

business rules applies to tickets whatever created by API or GUI. you can set technicians and goups by this way .   OR https://forum.glpi-project.org/viewtopic.php?id=158163

Thank for the explaination  and the post link. I can understand better.

Now, I Will do some tests for practice and later will try understand zabbix-side (if are using api or what) to communicate with glpi.

how it will be I don't know, because I'm very beginner in zabbix.

Thanks again.

Offline

#23 2019-09-20 20:42:29

mecmav
Member
From: Brasil
Registered: 2019-03-22
Posts: 326

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

Hello again to All

I'm here again, because I've made some tests and still in the same..

I can create tickerts on glpi by your API, working fine.

I will remember for you about my scenario: actually it's running a glpi 0.90 with integration with zabbix 3.0.25. Both system communicate to each other between plugin webservices. In the Zabbix side have scripts pointing to GLPI 0.90 in /usr/lib/zabbix/externalscripts and in the GLPI-side have an Zabbix agent pointing to Zabbix server. I know that plugin stopped your version till the GLPI 9.3. I know too that GLPI have a API to work with other applications. all that integration wasn't made by me, an another person did it a long time ago, and still running.

Now, I have a new instance of GLPI 9.4.2 that not work with webservices plugin and the Zabbix it's the same yet. But I'm with many doubts, already search for this integration, but all i've found it's by using the webservices plugin.

I did try follow this link https://janssenlima.blogspot.com/2013/1 … -glpi.html, but no success, because it's very old, it's using webservices plugin. I cannot found any topic by using native API for this integration.

Zabbix have a API too, but i have no idea to perform this integration.

Already turned the whole internet looking for practical answers, nothing yet.

Need help again, please.

Offline

#24 2019-09-20 20:44:11

mecmav
Member
From: Brasil
Registered: 2019-03-22
Posts: 326

Re: GLPI-API - Créer un appel dans GLPI via Zabbix

Already tried to read glpi and zabbix forums, but it's too hard for me while I'm search insistently.

Offline

Board footer

Powered by FluxBB