Hi,
I was trying to make a MS Power Automate for uploading attachments from a shared outlook inbox to Sharepoint.
The automation worked twice but the attachments wouldn't open- it gave this error when trying to open the PDF:
Error 1 opening file.
Could not open '21-608- RFI 078 (1).pdf' because it is either not a supported file type or the file has been corrupted. For example, it was sent as an email attachment and wasn't correctly decoded.
Then the automation started failing. Below is the code. Any ideas are much appreciated!
I was trying to make a MS Power Automate for uploading attachments from a shared outlook inbox to Sharepoint.
The automation worked twice but the attachments wouldn't open- it gave this error when trying to open the PDF:
Error 1 opening file.
Could not open '21-608- RFI 078 (1).pdf' because it is either not a supported file type or the file has been corrupted. For example, it was sent as an email attachment and wasn't correctly decoded.
Then the automation started failing. Below is the code. Any ideas are much appreciated!
JSON:
{
"type": "OpenApiConnection",
"inputs": {
"parameters": {
"mailboxAddress": "[email protected]"
},
"host": {
"apiId": "/providers/Microsoft.PowerApps/apis/shared_office365",
"connection": "shared_office365",
"operationId": "SharedMailboxOnNewEmailV2"
}
},
"recurrence": {
"frequency": "Minute",
"interval": 5
}
}
{
"type": "Foreach",
"foreach": "@triggerOutputs()?['body/value']",
"actions": {
"For_each_2": {
"type": "Foreach",
"foreach": "@triggerOutputs()?['body/value']",
"actions": {
"For_each_1": {
"type": "Foreach",
"foreach": "@item()?['attachments']",
"actions": {
"Create_file": {
"type": "OpenApiConnection",
"inputs": {
"parameters": {
"dataset": "https://harmonconst.sharepoint.com/sites/PM",
"folderPath": "/Shared Documents/005 HCI Accounting Attachments",
"name": "@item()?['name']",
"body": "@item()?['contentBytes']"
},
"host": {
"apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline",
"connection": "shared_sharepointonline-2",
"operationId": "CreateFile"
}
}
}
}
}
}
}
},
"runAfter": {}
}
{
"type": "Foreach",
"foreach": "@triggerOutputs()?['body/value']",
"actions": {
"For_each_1": {
"type": "Foreach",
"foreach": "@item()?['attachments']",
"actions": {
"Create_file": {
"type": "OpenApiConnection",
"inputs": {
"parameters": {
"dataset": "https://harmonconst.sharepoint.com/sites/PM",
"folderPath": "/Shared Documents/005 HCI Accounting Attachments",
"name": "@item()?['name']",
"body": "@item()?['contentBytes']"
},
"host": {
"apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline",
"connection": "shared_sharepointonline-2",
"operationId": "CreateFile"
}
}
}
}
}
}
}
{
"type": "Foreach",
"foreach": "@item()?['attachments']",
"actions": {
"Create_file": {
"type": "OpenApiConnection",
"inputs": {
"parameters": {
"dataset": "https://harmonconst.sharepoint.com/sites/PM",
"folderPath": "/Shared Documents/005 HCI Accounting Attachments",
"name": "@item()?['name']",
"body": "@item()?['contentBytes']"
},
"host": {
"apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline",
"connection": "shared_sharepointonline-2",
"operationId": "CreateFile"
}
}
}
}
}
{
"type": "OpenApiConnection",
"inputs": {
"parameters": {
"dataset": "https://harmonconst.sharepoint.com/sites/PM",
"folderPath": "/Shared Documents/005 HCI Accounting Attachments",
"name": "@item()?['name']",
"body": "@item()?['contentBytes']"
},
"host": {
"apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline",
"connection": "shared_sharepointonline-2",
"operationId": "CreateFile"
}
}
}
Attachments
Last edited by a moderator: