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 Yesterday 11:18:47

clem77
Member
Registered: Yesterday
Posts: 1

Upload document with Powerautomate / API

Hi everyone,

I set up a powerautomate to send email attachments to sharepoint. It works. Then I would like to send these attachments via an HTTP request to upload it to GLPI in document

To detail the processes used :

When an email arrives into sharedmailboxe OK
Create a file on Sharepoint OK
Get file contents in sharepoints OK
HTTP initSession OK


HTTP Upload >> /apirest.php/Document/

I paste you the code used for the upload part

"method": "POST",
    "headers": {
      "Session-Token": "@{outputs('jeton_session')}",
      "App-Token": "xxxxxxxxxxx",
      "Content-Type": "multipart/form-data
"body": {
      "$content-type": "multipart/form-data",
      "$multipart": [
        {
          "headers": {
            "Content-Disposition": "form-data; name=\"uploadManifest\""
          },
          "body": {
            "$content": "{\"input\": [{\"name\": \"@{outputs('Créer_un_fichier')?['body/Name']}\", \"_filename\": \"@{outputs('Créer_un_fichier')?['body/Name']}\"}]}"
          }
        },
        {
          "headers": {
            "Content-Disposition": "form-data; name=\"file\"; filename=\"@{outputs('Créer_un_fichier')?['body/Name']}\"",
            "Content-Type": "application/pdf"
          },
          "body": {
            "$content": "@{outputs('Créer_un_fichier')?['body/Name']}"
          }
        }
      ]
    } 


All the steps are OK on my powerautomate flow but I have no document on GLPI and this error in the file {/var/log/glpi/php-errors.log

glpiphplog.CRITICAL:   *** Uncaught Exception Error: Attempt to assign property "_filename" on null in /var/www/glpi/src/Api/APIRest.php at line 538
  Backtrace :
  src/Api/APIRest.php:133                            Glpi\Api\APIRest->parseIncomingParams()
  apirest.php:57                                     Glpi\Api\APIRest->call()
  public/index.php:82                                require()

The _filename property returns the name of the file to upload but the code must not be good.


Note that if I use postman it works

It would be great if someone could guide me. I think I'm not so far from the solution.

Thanks

Last edited by clem77 (Yesterday 11:25:42)

Offline

Board footer

Powered by FluxBB