This reposity aims to provide a working example of an upload through the Rest API of GLPI. We are using PHP Guzzle library to send http queries. See upload.php code for details.
- GLPI 9.2 (with api enabled)
- PHP >= 5.6
- Clone this repository on your computer.
- Move the directory into your http serveur vhost
- Run
composer install
to pull dependencies - Create a config.inc.php from config.inc.example file and fill parameters with your glpi instance data
- With your browser, got to the directory of this project and test the file upload and document creation.
$ 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": {...}}