Hi there,
we have created a custom App called “easyverein” for creating invoices in an external web-application “easyverein” via REST-API. Now, I want to upload an attachment from an incoming outlook e-mail to one specific invoice in “easyverein”.
The “easyverein” company wrote a hint for uploading file to an existing invoice.
Uploading a file isn’t possible for POST requests. It is possible to PATCH files though. Uploading with a PATCH just works like a normal PATCH but with a special header set:
'Content-Disposition': 'attachment; name="samplename"; filename="samplepicture.jpg"'
The body of the PATCH includes the key of the field to upload the file for (e.g. _profilePicture
) and a byte stream as value.
and a bash example:
url=‘https://easyverein.com/api/v2.0/member/{pk}/’
curl $url -X PATCH -H ‘Authorization: Bearer ’ -F ‘_profilePicture=@/path/to/your/file.png’
my challenge now is to map this bash function to my make scenario.
easyverein App Base:
{
// Default request configuration
“baseUrl”: “https://easyverein.com/api/v2.0”,
“headers”: {},
“response”: {
“error”: {
“message”: “[{{statusCode}}] {{body.error}}”
}}
}
easyverein module communication:
{
“url”: “/invoice/{{parameters.invoicenumber}}”, // Relative to base URL
“method”: “PATCH”,
“headers”: {
“Authorization”: “Bearer {{parameters.apiKey}}”,
“Content-Disposition”: “attachment; filename={{parameters.fileName}}”
},
“qs”: {},
“body”: {“path”: “{{parameters.path}}”
},
// Response handling
“response”: {
“output”: “{{body}}” // Returns no output bundle as no API output is expected.
},
“log”: {
“sanitize”: [“request.headers.Authorization”]
}
}
easyverein mappable parameters:
[
{
“name”: “apiKey”,
“type”: “text”,
“label”: “API Key”,
“required”: true
},
{
“name”: “invoicenumber”,
“type”: “number”,
“label”: “invoice Number”
},
{
“name”: “name”,
“type”: “text”,
“label”: “Image Name”
},
{
“name”: “fileName”,
“type”: “filename”,
“label”: “File name”,
“semantic”: “file:name”
},
{
“name”: “path”,
“type”: “buffer”,
“label”: “File Data”,
“semantic”: “file:data”
}
]
and the module in my scenario
the header response code is 200, but the “path” in the body response is empty and should be filled with the uploaded file path.
e.g.
{
"path": "https://easyverein.com/app/file?category=invoice&path=2022/01/Rechnungen/1655234658-TFF-2022-1207.pdf&storedInS3=True",
"relatedAddress": null,
"payedFromUser": null,
"org": "https://easyverein.com/api/v2.0/organization/1803",
"invNumber": "TFF-2022-1207",
"date": "2022-06-14",
"id": 123456789,
"totalPrice": "150.00",
"tax": "0.00",
"taxRate": "0.00",
"taxName": null,
"receiver": "xyz",
"paymentDifference": "0.00",
"isDraft": false,
"gross": false,
"actualCallStateName": "Offen, heruntergeladen"
},