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 2022-10-09 02:27:16

wbsilva
Member
Registered: 2022-10-09
Posts: 2

Create ITILCategory via API

Hello!

I am trying to create an ITILCategory using the code bellow:

baseURL = "https://glpi.somedomain.com"
apiToken = "xxxxxx"
usrToken = "xxxxxx"

url = baseURL + '/apirest.php/ITILCategory'
print(url)
headers = {
      'App-Token': apiToken,
      'Content-Type': 'application/json',
      'Session-Token': sSessionToken
}
body =  {
    "input": {
        #"id":1,
        "entities_id":0,
        "is_recursive":1,
        "itilcategories_id":0,
        "name":"teste",
        "completename":"teste",
        "comment":"",
        "level":1,
        "knowbaseitemcategories_id":0,
        "users_id":0,
        "groups_id":10,
        "code":"",
        "ancestors_cache":"[]",
        "sons_cache":0,
        "is_helpdeskvisible":1,
        "tickettemplates_id_incident":1,
        "tickettemplates_id_demand":1,
        "changetemplates_id":1,
        "problemtemplates_id":1,
        "is_incident":1,
        "is_request":1,
        "is_problem":1,
        "is_change":1, 
    }
}
sResult = requests.post(url,headers=headers,data=body)

I ommited the initsession part of the code. I am getting the following error:
"'["ERROR_JSON_PAYLOAD_INVALID","JSON payload seems not valid"]"

Does anybody has any idea?

Thanks

Offline

#2 2022-10-10 23:53:59

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

Re: Create ITILCategory via API

Does your "id" property have this "#" before it in its actual request? This would not be valid as the JSON specification has no way of specifying comments.


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

Board footer

Powered by FluxBB