You are not logged in.
Pages: 1
Hi guys, I'm tryung to create a ticket in GLPI, using python requests. My code:
from glpi import GLPI
import requests
url = 'https://hd.integrasky.ru/apirest.php/initSession'
auth = ('username', 'password')
headers = {'App-Token': 'token',
'Content-Type': 'application/json'}
requests.get(url, auth=auth, headers=headers)
payload = {'input': {'name': 'Проблема', 'content': 'Не работает компьютер', 'entities_id': 29}}
requests.post('http://hd.integrasky.ru/apirest.php/Ticket', json=payload)
But the ticket is not creating, and there is no exception in my script.
Process finished with exit code 0
What I'm doing wrong? Someone can help me?
And should I use encoding to utf-8 to russian text?
Offline
initsession should return a session_token.
add this session_token to headers to call other endpoints ( .../Ticket)
Trouver la panne avant de réparer...
GLPI10.0.16 (ubuntu 22.04 PHP8.1 Mariadb10.6 ) plugins : comportements 2.7.3 reports 1.16.0 formcreator 2.13.9, datainjection 2.13.5 fields 1.21.9
Offline
Any news? ^^
Offline
hi
in this code:
--------------------------------
from glpi import GLPI
import requests
url = 'SITE/apirest.php/initSession'
auth = ('username', 'password')
headers = {'App-Token': 'token',
'Content-Type': 'application/json'}
requests.get(url, auth=auth, headers=headers) #this GET is when you obtain the token, but you are losing the token, you need to save in a STRING to use in the next line in a HEADER of the POST
----------------------------------------------------
in this line you need to add the token of the last line
----------------------------------------------------
requests.post('http://SITE/apirest.php/Ticket', json=payload)
----------------------------------------------------
i am in this code in this moment, if i win, i will show you
Offline
Pages: 1