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-05-15 14:44:31

jonatasilva
Member
Registered: 2023-03-28
Posts: 3

changing the Assignee in a ticket via the glpi api and it is not worki

I'm facing an issue when trying to add a group to the assignment box via the GLPI API and then closing the ticket using cURL for validation. I'm using some cURL commands with PUT requests. I receive a success status, but upon checking the interface, the ticket in question doesn't undergo any changes in the desired column. My goal is to add a Zabbix Server script via JavaScript to send a request for ticket closure when a machine enters the "resolved" status in the trigger.

Currently, I'm using the following cURL request to validate the change of group:

bash
Copiar código
curl --request PUT \
--url https://glipiserver/apirest.php/Ticket/29303 \
--header 'User-Token: your token' \
--header 'Session-Token: your session token' \
--header 'Content-Type: application/json' \
--data '{
    "input": {
        "groups_id": 2,
        "type": 2
    }
}'


And to execute the ticket closure, I'm using this:

bash
Copiar código
curl --request PUT \
--url https://glipihost/apirest.php/Ticket/29303 \
--header 'User-Token: your user token' \
--header 'Session-Token: your session token' \
--header 'Content-Type: application/json' \
--data '{
    "input": {
        "status": 6,
        "users_id_recipient": 35,
        "groups_id": 3,
        "requesttypes_id": 1,
        "urgency": 4,
        "impact": 3,
        "priority": 4,
        "itilcategories_id": 871,
        "type": 1,
        "global_validation": 1,
        "slas_id_ttr": 15,
        "slas_id_tto": 12,
        "slalevels_id_ttr": 0,
        "time_to_resolve": "2024-05-17 13:05:47",
        "time_to_own": "2024-05-15 10:05:47",
        "begin_waiting_date": null,
        "sla_waiting_duration": 0,
        "ola_waiting_duration": 0,
        "olas_id_tto": 0,
        "olas_id_ttr": 27,
        "olalevels_id_ttr": 0,
        "ola_ttr_begin_date": "2024-05-14 15:29:45",
        "internal_time_to_resolve": "2024-05-16 08:29:45",
        "internal_time_to_own": null,
        "waiting_duration": 0,
        "close_delay_stat": 0,
        "solve_delay_stat": 0,
        "takeintoaccount_delay_stat": 535,
        "actiontime": 0,
        "is_deleted": 0,
        "locations_id": 0,
        "validation_percent": 0
    }
}'

Thank you in advance for your help

Offline

#2 2024-05-15 14:56:42

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 6,287

Re: changing the Assignee in a ticket via the glpi api and it is not worki

to ADD a group to a ticket :
USE POST method


$input='{ "input": {"tickets_id": '.$ticket_id.' ,"groups_id": '.$group_id.',"type": "2","use_notification": "1"}}';
$url=".../glpi/apirest.php/Ticket/".$ticket_id."/group_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

#3 2024-05-15 15:00:04

LaDenrée
HELPER
Registered: 2012-11-19
Posts: 6,287

Re: changing the Assignee in a ticket via the glpi api and it is not worki

to close ticket check if "API account active profile" can solve without solution, life cycle allows to close from currrent status, some other rules prevents from closing ticket (user or group missing, time missing,  to do tasks,...).


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

#4 2024-05-15 15:55:12

jonatasilva
Member
Registered: 2023-03-28
Posts: 3

Re: changing the Assignee in a ticket via the glpi api and it is not worki

Hello, I managed to send the request, but now the error was You do not have permission to perform this action
the strange thing is that I'm using an admin user to send the request.
command used:
curl --request POST   --url https://glpihost/apirest.php/Ticket/29303/Group_Ticket/  --header 'User-Token: your user-token'   --header 'Session-Token: your session'   --header 'Content-Type: application/json'   --data '{
    "input": {
        "groups_id": "2",
        "type": "2",
        "use_notification": "1"
    }
}'

here is the group id:

{
        "id": 2,
        "entities_id": 11,
        "is_recursive": 1,
        "name": "Support N1 ",
        "Comment": "",
        "ldap_field": null,
        "ldap_value": null,
        "ldap_group_dn": null,
        "date_mod": "11/10/2023 08:59:41",
        "groups_id": 0,
        "full name": "Support N1 ",
        "level 1,
        "ancestors_cache": "[]",
        "sons_cache": "{\"2\":2}",
        "is_requester": 1,
        "is_watcher": 1,
        "is_assign": 1,
        "is_task": 1,
        "is_notify": 1,
        "is_itemgroup": 0,
        "is_usergroup": 1,
        "is_manager": 1,
        "creation_date": "03/01/2023 15:06:59",
        "links": [
            {
                "rel": "Entity",
                "href": "https://yourglpihost/apirest.php/Entity/11"
            }
        ]
    },

my user session information

:
{
    "active_profile": {
        "id": 4,
        "name": "Super Administrator",
        "interface": "central",
        "is_default": 0,

"user": 7327,
        "entities": {
            "11": {
                "id": 11,
                "name": "WESAFER",
                "is_recursive": 1
            }
        }
    }
}

Offline

Board footer

Powered by FluxBB