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 2024-04-12 11:59:35

malekhammou
Member
Registered: 2024-04-12
Posts: 3

Get TicketTemplate item via API ["ERROR_RIGHT_MISSING"]

Hello,

I hope you are doing well.

I am using the rest API in the context of an automation project. So far, I have been able to use it to get items like software, appliance, etc.. However, when I try to make a get request to get the list of items of type TicketTemplate I get the following error even though I have super admin rights.

["ERROR_RIGHT_MISSING","You do not have the required rights to perform this action."]

I used the script below for appliance, computer, and software and it worked well.


#!/bin/bash


. glpi_api.config


INIT_SESSION_URL="$GLPI_API_URL/apirest.php/initSession"



TEMPLATES_URL="$GLPI_API_URL/apirest.php/TicketTemplate/?range=$MIN-$MAX"


INIT_SESSION_REQUEST=$(curl -X GET \
  -H 'Content-Type: application/json' \
  -H "App-Token:$APP_TOKEN" \
  -H "Authorization: Basic $CREDENTIALS" \
  $INIT_SESSION_URL)

SESSION_TOKEN=$(echo  $INIT_SESSION_REQUEST | jq -r '.session_token')



GET_TEMPLATES_REQUEST=$(curl -X GET \
-H 'Content-Type: application/json' \
-H "App-Token: $APP_TOKEN" \
-H "Session-Token: $SESSION_TOKEN " \
$TEMPLATES_URL )

echo $GET_APPLIANCES_REQUEST



Since I couldn't find a complete list of the itemType parameter, I relied on the names of the PHP classes inside the code.

Thank you very much for your help.


Regards,

Malek

Last edited by malekhammou (2024-04-12 13:36:09)

Offline

#2 2024-04-13 03:43:49

cconard96
Moderator
Registered: 2018-07-31
Posts: 2,809
Website

Re: Get TicketTemplate item via API ["ERROR_RIGHT_MISSING"]

Is the Super-Admin profile set as the default profile for that user? You may need to change profiles before making the request. /apirest.php/TicketTemplate looks like the correct URL.

Check the profile being used:
/apirest.php/getActiveProfile/

Change active profile:
/apirest.php/changeActiveProfile/
Body:
{
    "profiles_id": PROFILE_ID
}

For the supported itemtypes, they correspond with the PHP class names. If the class has CommonDBTM as a parent class either directly or indirectly (and isn't an abstract class), it should work with the API.


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

#3 2024-04-15 11:09:16

malekhammou
Member
Registered: 2024-04-12
Posts: 3

Re: Get TicketTemplate item via API ["ERROR_RIGHT_MISSING"]

Thank you very much! Your answer helped me solve my problem. Even though the profile on the web GUI was set to super-admin, for some reason the API profile was set to self-service. I had to update manually.

Regards,

Malek

Offline

Board footer

Powered by FluxBB