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 2018-09-02 18:19:40

jaisinghotra
Guest
Registered: 2018-09-02
Posts: 1

Create a ticket using python requests any help?

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

#2 2018-09-06 10:22:15

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 4,285

Re: Create a ticket using python requests any help?

initsession should return a session_token.

add this session_token to headers to call other endpoints  ( .../Ticket)


Trouver la panne avant de réparer...
*GLPI 9.1.6+fusion9.1+1.1+behaviours1.5.0+reports+fields+appliances+pdf+badges+formcreator2.5.2 PHP7.0 Mariadb10
*GLPI 9.2.4(behaviours1.5.2+fusion9.2+1.0+applicatifs2.3.0+dashboard 0.8.9)hebergé sur serveur mutualisé.
*GLPI 9.3.3  en test (ubuntu 18.04 mariadb 10.2.4)

Offline

Board footer

Powered by FluxBB