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 2019-11-12 18:44:21

GGA
Member
Registered: 2019-11-12
Posts: 3

Get attachments

Hi,

I cannot understand how to download attachments of a 'ticket' item, using REST API.
I can see upload samples but no download sample.
I'm using POSTMAN tool to make REST API calls.
When trying to get an attachment, I get following 401 error: "Vous n'avez pas les droits requis pour réaliser cette action."

My queries :
- GET 1 ticket: GET https://xxx/apirest.php/ticket/2116 => works well
- SEARCH docs: GET https://xxx/apirest.php/search/document => error 401
- GET 1 attachment: GET https://xxx/apirest.php/document?id=13&alt=media => error 401

May anyone help me?
Are my queries valid?
What are necessary rights to perform such operation?

Regards,
Guillaume

Offline

#2 2019-11-12 19:09:08

mecmav
Member
From: Brasil
Registered: 2019-03-22
Posts: 326

Re: Get attachments

Try this
https://xxx/apirest.php/search/document/id

You are using a invalid URL to return data from API

Offline

#3 2019-11-13 10:01:28

GGA
Member
Registered: 2019-11-12
Posts: 3

Re: Get attachments

Hi mecmav, thanks for your help.

My issue regarding 401 error was a configuration error.
Using web site, I was able to see attachments of a ticket inside ticket itself.
But I was not able to see the 'Document' sub menu entry inside Managment menu.

Administrator provided me enough rights to see this menu and sub-menu.
Once done, the query below gives me the attached documents of a ticket:
https://xxx/apirest.php/ticket/2116?with_documents=true

Last edited by GGA (2019-11-14 00:02:00)

Offline

#4 2019-11-14 00:05:34

GGA
Member
Registered: 2019-11-12
Posts: 3

Re: Get attachments

If that can help anyone here below are necessary queries to manage tickets and associated documents:

Get an item by id (2116) and all attachments information:
This allow you to retreive document ids associated to a ticket (here below 1023)
https://xxx/apirest.php/ticket/2116?with_documents=true

Search a document by id:
https://xxx/apirest.php/search/document?criteria[0][field]=2&criteria[0][searchtype]=equal&criteria[0][value]=1023

Get a document by id:
https://xxx/apirest.php/document/1023

Download a document by id:
https://xxx/apirest.php/document/1023?alt=media

Offline

#5 2022-01-11 14:53:43

econdepires
Member
Registered: 2022-01-11
Posts: 4

Re: Get attachments

That last one "https://xxx/apirest.php/document/1023?alt=media" didn't work for me.

The request actually works, but the downloaded file is 0B...

Can anyone help me?

Thanks in advance!

Offline

Board footer

Powered by FluxBB