Api - glpi

gentlemen, I’m trying to create a call in GLPI through the API provided by the tool. The documentation asks you to do the following:

curl -X POST -H ‘Content-Type: application/json’ -H “Session-Token: xxxxxxxx” -d ‘{“input”: {“name”: “Ticket Name”, “content”: “Ticket Desc”}}’ ‘http://glpiserver/apirest.php/Ticket/

the URL is: http://xxx/apirest.php/Ticket/

for the input:

name: ticket title
content: ticket description
itilcategories_id: ticket category id
type: ticket type id
locations_id : location id

you get session token from initsession:
$ curl -X GET
-H ‘Content-Type: application/json’
-H “Authorization: Basic base64({login}:{password})”
-H “App-Token: f7g3csp8mgatg5ebc5elnazakw20i9fyev1qopya7”
http://xxx/apirest.php/initSession

my difficulty is in the parameters below:

for the input:

name: ticket title
content: ticket description
itilcategories_id: ticket category id
type: ticket type id
locations_id : location id

I did it this way, but it returns a message I think I must be doing something wrong but I don’t know how it should be, can someone help me?

Hi @Rodrigo_Lima, welcome to the community!

This looks like an error coming from the API you are calling, seemingly complaining about a bad array. Your request doesn’t seem to require an array though, so I am not 100% sure what’s needed here. Perhaps you can check with the team managing the API you are calling how exactly your request should look like?

Rodrigo, I’m passing through the same issues. Ive been using GLPI API. BTW, i send you a message. Hope we help each other

I’m not sure if you’ve already solved this issue, but the new version of n8n has an option to import a curl command, and it helped me solve this problem.

1 Like

Hello guys.
I’ve been trying to do the same, using Python and curl.

I got the same error or 200 OK but no update.

Did you guys happen to know the solution?

Thanks

hi there,
I’m creating GLPI integration with n8n and I’ve map main functions. In the future, I belive to upgrade it to a node for the comunity.
The GLPI’s API request two steps to do anythink.

  1. Use app-key and user-token to get session-key
  2. Use session-key to make your real request such like search or update items.
-- geting session token
curl -X GET \
-H 'Content-Type: application/json' \
-H "Authorization: user_token MyUserTokenGeneratedByGLPI" \
-H "App-Token: MyAppTokenGeneratedByGLPI" \
'https://my-glpi/apirest.php/initSession'



-- making a simple search for a new tickets
curl -X GET \
-H 'Content-Type: application/json' \
-H "Session-Token: SessionTokenReturnedFromINITSESSION" \
-H "App-Token: MyAppTokenGeneratedByGLPI" \
'https://my-glpi/apirest.php/search/Ticket'?\
'criteria\[0\]\[link\]=AND&'\
'criteria\[0\]\[field\]=12&'\
'criteria\[0\]\[searchtype\]=equals&'\
'criteria\[0\]\[value\]=1'

The ‘criteria’ can be found using chrome dev tools. When you click into search button at Tickets page, a http_request are called with the same extructure.

If it works at console, you can copy and paste the curl command into an Http request node and n8n will configure the node for you.