You are not logged in.
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
I have found a error in my request and now working fine.
Offline
Hello,
What was your error ?
Offline
Hello,
What was your error ?
In the Postman, I miss set multipart/form-data in the request
Offline
What's happening with your request try?
Offline
I have translated the request in php curl and got the same error, although I know this is not a size issue..
Offline
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
Hello mecmav,
I am trying to upload document from powershell but unable to find the good syntax.
And i would like to try learn more from postman, could you help me (and us) and said me how put theses settings to uploaded document from postman ?
Thank's for your help.
Offline
Hello mecmav,
I am trying to upload document from powershell but unable to find the good syntax.
And i would like to try learn more from postman, could you help me (and us) and said me how put theses settings to uploaded document from postman ?
Thank's for your help.
what error you are getting?
With Postman, you can simulate your requests with data that you use in glpi.
Try put a printscreen of your error here
Offline
Thank's for your time
I have created my account only this day
And body (with error)
And i don't know if i must put anything in Tests ?
(Thank's you again)
Offline
Thank's for your time
I have created my account only this day
https://i.ibb.co/zNNfsS6/Postman-Setdoc01.pngAnd body (with error)
https://i.ibb.co/xsXY0mP/Postman-Setdoc02.png
And i don't know if i must put anything in Tests ?
(Thank's you again)
Hello,
Are you trying to upload a single document to glpi, or you trying upload a document and attach to a ticket??
Offline
I have trying both
And in this capture i try to upload document to ticket 161
Offline
I have trying both
And in this capture i try to upload document to ticket 161
For each of this, you need make first a request in API to insert a document file in glpi.
After that you need do another request to make the relationship between the document that was uploaded with the type of object you want (e.g ticket, problem, contract, etc).
Tomorrow I can explain these methods, you can call me at personal email.
My email it's the same as the my username here in the forum. The domain of my email is hotmail.
So my email is my username@hormail.com
I need say this way for prevent phishing or spamming crawlers found my email.
Offline
Do not go to email as I will lose the conversation :-)
Or come back with a solution :-D
Offline
I did some tests, and working fine.
Using Postman I can insert a document and later relate this file to a ticket or any other object type.
Offline
Do not go to email as I will lose the conversation :-)
Or come back with a solution :-D
Yes if i try with success to put a document with Postman i come back here to insert screens to help ohter.
And For your code from your module, i think we must try to add document and assign after it to ticket. (maybe api../ticket/document) does not work directly
I did some tests, and working fine.
Using Postman I can insert a document and later relate this file to a ticket or any other object type.
Could you send, as me the sceenshots from the postman ? (or you want only by mail ?)
Offline
You need have the files that you want to insert in glpi:
Here I have 2 files named (test.txt, teste.txt)
We will use any of them files.
In Postman, you will need make a first request to insert and create a file in glpi
For do that, you will need follow these settings:
Define the headers and body request
URL: yourinstance/apirest.php/Document
Use the Content-Type given by Postman (but review if is defined to multipart/form-data; boundary=<calculated...)
Your App-Token and Session-Token (here I assuming that you already did the initSession method)
Go to the Body Tab
Select "form-data" radio button
Inform the 2 parameters:
uploadManifest
filename
In the "uploadManifest" (must be text format) you send the input data (JSON format) for insert register in glpi database:
In the "filename" (must be in file format), you select directly your file clicking in the button "Select File":
Now you need send your request and analyze the result:
Now you have the response. If a correct request was sent, you will need get "201 Created" status response.
In the GLPI, go to Management > Documents, and you will see the created item:
Offline
Thank's a lot !
My error was to define mine Content-Type in Headers.
To working, you must display the hidden Keys (add only the App-Token & Session-token)
Thank's you Mecmav ..!
Offline
in POST data pass the json_encode string instead of Array.
$parameters["input"] = [
"entities_id" => 0,
"name" => "Printer ribbin issue",
"content" => "comment from Spot's input",
];
$json_param = json_encode($parameters);
Offline
Hello, after sucessfull upload a document, how can I set the documento to ticket?
I'm trying a post on:
app key and session key ok
ticket is 49069 and id of document is 14004
https://[site]/apirest.php/Ticket/49069/Document
{
"input": {
"items_id": "49069",
"itemtype": "Ticket",
"id": "14004"
}
}
But I receive this error:
[
"ERROR_GLPI_ADD",
""
]
Offline
The current API is a little quirky.
/Ticket/{tickets_id}/Document actually refers to the "Document" item class, not documents linked to Tickets. The actual documents are represented by the "Document" class, while the links between Documents and other items/tickets is "Document_Item".
You may be able to do:
/Ticket/49069/Document_Item
{
"documents_id": 14004
}
If not, this should definitely work:
/Document_Item
{
"documents_id": 14004,
"itemtype": "Ticket",
"items_id": 49069
}
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
Thanks for the quick response, it worked here! I needed to do this action using the administrator token.
Is it possible to upload a file in a ticket interaction via API too? I tried searching this documentation or finding examples, but I didn't find anything.
When I finish here I will share my php script to help other users with the same needs as mine.
The current API is a little quirky.
/Ticket/{tickets_id}/Document actually refers to the "Document" item class, not documents linked to Tickets. The actual documents are represented by the "Document" class, while the links between Documents and other items/tickets is "Document_Item".
You may be able to do:
/Ticket/49069/Document_Item
{
"documents_id": 14004
}If not, this should definitely work:
/Document_Item
{
"documents_id": 14004,
"itemtype": "Ticket",
"items_id": 49069
}
Offline
If you haven't already, please check the API documentation for uploading a document.
/apirest.php#upload-a-document-file
This URL is relative to your GLPI URL.
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
Yes, I can upload a document.
I see 2 types of uploads on a ticket:
1 - upload document and link to ticket
2 - upload document inside interaction (on glpi interface), its possible do this upload inside post a interaction (followup)?
Image below with same image in different upload methods.
If you haven't already, please check the API documentation for uploading a document.
/apirest.php#upload-a-document-file
This URL is relative to your GLPI URL.
Last edited by leolage (2024-02-09 17:21:39)
Offline
2 - upload document inside interaction (on glpi interface), its possible do this upload inside post a interaction (followup)?
Yes. Instead of associating the document with the ticket, associate it with the followup after the followup is created.
itemtype: "ITILFollowup"
items_id: YOUR_FOLLOWUP_ID
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