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-10-28 22:32:50

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

Uploading document or file through API

Hello again to all

I trying to upload a file to GLPI, I've already did initSession, working fine.

I'm Using PostMan to do that. Reading docs i need set uploadManifest and value {"input": {"name": "Subindo docs", "_filename" : ["C:/teste.txt"]}};type=application/json' but I get this response: [
    "ERROR_UPLOAD_FILE_TOO_BIG_POST_MAX_SIZE",
    "The file seems too big"
]

Another way I try use a lib from https://github.com/orthagh/glpi_api_upload and put on my glpi.
When I upload a doc, nothing happens, the screen empty data.

How can I use the above explanation?

Additional Curl example
$ curl -X POST \
-H 'Content-Type: multipart/form-data' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
-F 'uploadManifest={"input": {"name": "Uploaded document", "_filename" : ["file.txt"]}};type=application/json' \
-F 'filename[0]=@file.txt' \
'http://path/to/glpi/apirest.php/Document/'

< 201 OK
< Location: http://path/to/glpi/api/Document/1
< {"id": 1, "message": "Document move succeeded.", "upload_result": {...}}

Offline

#2 2019-10-29 13:53:00

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

Re: Uploading document or file through API

I have found a error in my request and now working fine.

Offline

#3 2020-01-23 15:17:16

ben2249
Member
From: FRANCE
Registered: 2019-12-03
Posts: 35

Re: Uploading document or file through API

Hello,

What was your error ?

Offline

#4 2020-01-23 17:00:39

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

Re: Uploading document or file through API

ben2249 wrote:

Hello,

What was your error ?

In the Postman, I miss set multipart/form-data in the request

Offline

#5 2020-01-23 17:01:19

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

Re: Uploading document or file through API

What's happening with your request try?

Offline

#6 2020-01-23 17:03:39

ben2249
Member
From: FRANCE
Registered: 2019-12-03
Posts: 35

Re: Uploading document or file through API

I have translated the request in php curl and got the same error, although I know this is not a size issue..

Offline

#7 2020-01-23 17:28:20

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

Re: Uploading document or file through API

ben2249 wrote:

I have translated the request in php curl and got the same error, although I know this is not a size issue..

Really, this is not error from the size of the file.

Review your request, if you're using Postman, set uploadManifest, this error gone, At least for me.

Try put your code, maybe I can help you.

Offline

Board footer

Powered by FluxBB