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 2023-01-12 11:48:25

aziz
Member
Registered: 2021-03-30
Posts: 109

How to POST/GET ticket Documents

Hello guys, I'm working on a mobile app for GLPI I'm working on the Actions historical part of a ticket and I want to add the possibility to add a document :

https://imgur.com/a/FhkS55V

I didn't figure out how to get the documents added to a ticket and how to post a document using API, mainly an Image.
Because when I'm using this endpoint to get the documents of the ticket (id:x):
http://server/glpi/apirest.php/ticket/x/document

I get this response

[
    {
        "id": 3,
        "entities_id": 0,
        "is_recursive": 0,
        "name": "Document: Ticket - tt",
        "filename": "compressor.png",
        "filepath": "PNG/21/9873b49c8f9888f6e12ea1a24a206a9ba02b2e.PNG",
        "documentcategories_id": 0,
        "mime": "image/png",
        "date_mod": "2023-01-11 19:37:27",
        "comment": null,
        "is_deleted": 0,
        "link": null,
        "users_id": 4,
        "tickets_id": 210,
        "sha1sum": "219873b49c8f9888f6e12ea1a24a206a9ba02b2e",
        "is_blacklisted": 0,
        "tag": "6ea43817-d985547e-63bf01e58f4620.10794953",
        "date_creation": "2023-01-11 19:37:27",
        "links": [
            ...
        ]
    }
]

So my question is how can I get the actual document or in this case the image from this API response ?
And how can I POST an image for a specific ticket if I wanted to.
I appreciate any help smile

Offline

#2 2024-02-08 17:11:23

leolage
Member
Registered: 2020-10-28
Posts: 6

Re: How to POST/GET ticket Documents

Hello, did you find a solution to your question?

Offline

#3 2024-02-08 23:01:04

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

Re: How to POST/GET ticket Documents

Use "/front/document.send.php?docid=DOCUMENT_ID" where the URL is relative to your GLPI and replace DOCUMENT_ID with the ID of the document.


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

#4 2024-02-12 22:26:51

arturferrira
Member
From: Natal-RN - Brasil
Registered: 2023-09-16
Posts: 1

Re: How to POST/GET ticket Documents

Excellent, I had come across this solution but I didn't know if it would be correct to use it this way.

Offline

#5 2024-02-12 22:59:04

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

Re: How to POST/GET ticket Documents

That is the correct way to use it.
In fact, in the next main version of GLPI (10.1), there will be another REST API which is less close to the code and more user friendly and it will return this link rather than the internal path since the internal filepath means nothing to anyone using 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

Board footer

Powered by FluxBB