You are not logged in.
Pages: 1
Hi Everyone!
I have an issue with the Problem Apirest. I want to create tickets from Zabbix using the Zabbix GLPI Webhook media type but is not working, the API is responding with a 200 False all the time. I thought that was a problem with the media type script and I tried to send a request using cURL and the result is the same.
This is my current setup:
OS: Ubuntu 22.04.4 LTS
GLPI: 10.0.12
Zabbix: 6.4.13
This is the Zabbix log:
Media type test log
00:00:00.116 [Debug] [ GLPi Webhook ] Sending request: http://172.16.18.68/apirest.php/Problem/ {"input":{"name":"{ALERT.SUBJECT}","content":"{ALE RT.MESSAGE}\n<a href=http://172.16.5.10/tr_events.php?triggerid={TRIGGER.ID}&eventid={EVEN T.ID}>Link to problem in Zabbix</a>","status":1,"urgency":"{EVENT.NSEVERITY}"}}
00:00:00.189 [Debug] [ GLPi Webhook ] Received response with status code 200
00:00:00.189 [Debug] [ GLPi Webhook ] Failed to parse response received from GLPi
00:00:00.189 [Debug] [ GLPi Webhook ] ERROR: Failed to process response received from GLPi. Check debug log for more information.
This is the GLPI Api log:
...
Enpoint 'Problem' called by 172.16.5.10 (zabbix)
2024-04-11 23:01:12 [8@ip-172-16-18-68]
Enpoint 'Problem' called by 172.16.5.10 (zabbix)
2024-04-11 23:08:00 [8@ip-172-16-18-68]
Enpoint 'itilproblem' called by 172.16.5.10 (zabbix)
2024-04-11 23:12:03 [8@ip-172-16-18-68]
Enpoint 'problem' called by 172.16.5.10 (zabbix)
2024-04-11 23:12:24 [8@ip-172-16-18-68]
Enpoint 'Problem' called by 172.16.5.10 (zabbix)
2024-04-11 23:23:16 [8@ip-172-16-18-68]
Enpoint 'Problem' called by 172.16.5.10 (zabbix)
2024-04-11 23:24:28 [@ip-172-16-18-68]
Enpoint 'Problem' called by 172.16.16.87
2024-04-11 23:24:36 [@ip-172-16-18-68]
Enpoint 'Problem' called by 172.16.16.87
2024-04-11 23:28:22 [8@ip-172-16-18-68]
Enpoint 'shatever' called by 172.16.5.10 (zabbix)
2024-04-11 23:31:37 [8@ip-172-16-18-68]
Enpoint 'problems' called by 172.16.5.10 (zabbix)
2024-04-11 23:31:59 [8@ip-172-16-18-68]
Enpoint 'Problems' called by 172.16.5.10 (zabbix)
2024-04-11 23:32:22 [8@ip-172-16-18-68]
Enpoint 'Problem' called by 172.16.5.10 (zabbix)
Here is my cURL request:
curl -vX POST \
-H 'Content-Type: application/json' \
-H "Session-Token: TheToken" \
-d '{"input":{"name":"{ALERT.SUBJECT}","content":"{ALERT.MESSAGE}\n<a href=http://172.16.5.10/tr_events.php?triggerid={TRIGGER.ID}&eventid={EVENT.ID}>Link to problem in Zabbix</a>","status":1,"urgency":"{EVENT.NSEVERITY}"}}' \
'http://172.16.18.68/apirest.php/Problem'
And this is the response:
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 172.16.18.68:80...
* Connected to 172.16.18.68 (172.16.18.68) port 80 (#0)
> POST /apirest.php/Problem HTTP/1.1
> Host: 172.16.18.68
> User-Agent: curl/7.81.0
> Accept: */*
> Content-Type: application/json
> Session-Token: TheToken
> Content-Length: 219
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Fri, 12 Apr 2024 14:45:05 GMT
< Server: Apache/2.4.52 (Ubuntu)
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate
< Pragma: no-cache
< Content-Length: 0
< Content-Type: text/html; charset=UTF-8
<
* Connection #0 to host 172.16.18.68 left intact
Offline
You seem to be missing an app token.
You should be making a call to /apirest.php/initSession/ first with an app_token and user_token query parameter to get a session token. This session token does expire after some time.
Further calls to the API should provide that session_token query parameter (or Session-Token header) and app_token parameter (or App-Token header).
Although, I'm not sure why you are getting an empty response with a 200 status.
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
Hi cconard96, Thanks for your response.
I don't have issues with the initSession, that is working fine. I'm able to make a request and get the session token. My problem is with the apirest.php/Problem, no matter what I do I always receive an empty response with a 200 status.
I'll build another GLPI machine and check if I have the same result, also I'll try the 10.0.14 to see if that solves my problem.
Offline
Hi everyone!
I found the issue after check the php-error.log file
[2024-04-15 15:01:31] glpiphplog.CRITICAL: *** Uncaught Exception TypeError: Unsupported operand types: int << string in /var/www/html/glpi/src/CommonITILObject.php at line 2583
Backtrace :
src/Problem.php:298 CommonITILObject->prepareInputForAdd()
src/CommonDBTM.php:1297 Problem->prepareInputForAdd()
src/Api/API.php:1856 CommonDBTM->add()
src/Api/APIRest.php:317 Glpi\Api\API->createItems()
apirest.php:57 Glpi\Api\APIRest->call()
public/index.php:82 require()
As you can see, the event severity can't be a string, it must be an Integer.
Offline
Pages: 1