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-07-13 12:28:15

supertramp4
Member
Registered: 2022-06-13
Posts: 28

Example api for CronTask

Hi,
GLPI 10.0.2
Can you give guidance for the correct syntax for calling the crontask via API. II want to be able to start the mailgate so that it can retrieve emails.
NOTE I specifically want to try API, as calling the normal /front/cron.php is not working as expected.

In automatic notifications the mailgate task would be http://<domain>/front/crontask.form.php?id=9

I have a valid session
C:\curl>c:\curl\bin\curl -H "Content-Type: application/json" -H "Authorization: user_token xxx" -H "App-Token: xxx" -X GET hxxp://<domain>/apirest.php/initSession
{"session_token":"ifa57d204rn5thq42bigbti0pi"}

the following returns an error
C:\curl>c:\curl\bin\curl -H "Content-Type: application/json" -H "Session-Token: ifa57d204rn5thq42bigbti0pi" -H "App-Token: xxx" -d "{"input": {"id": 9}}" -X PUT hxxp://<domain>/apirest.php/CronTask

["ERROR_JSON_PAYLOAD_INVALID","JSON payload seems not valid"]

Offline

#2 2022-07-13 18:56:11

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

Re: Example api for CronTask

Hello, it is not possible to start a CronTask via the API. You can use the API to change the status property of actions but that wouldn't trigger them to start.


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