0

Hello I have a logic app that looks for email attachments, I made an HTTP request to upload this file into a temporary blob storage. When I open my pdf file it is empty.

enter image description here

I have a variable where I put the file content and send it as body in the HTTP Request and It looks like this

enter image description here

I need to upload any type of files and I am getting this problem only with files that are not text

RithwikBojja
  • 5,069
  • 2
  • 3
  • 7
  • It would be good if you show a snapshot of your entire workflow so everyone knows what connectors are being used. Also, why are you using a Rest api to put a blob instead of the native Logic app to Blob coonnector? – Anupam Chand Jul 19 '23 at 16:40

2 Answers2

0

I have reproduced in my environment and got expected results as below:

Design:

You have connector called as Azure blob Storage (In that connector you can use action called as Create blob (V2) like below):

enter image description here

Output:

enter image description here

In storage account:

enter image description here

Codeview:

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Create_blob_(V2)": {
                "inputs": {
                    "body": "@variables('var1')",
                    "headers": {
                        "ReadFileMetadataFromServer": true
                    },
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['azureblob_1']['connectionId']"
                        }
                    },
                    "method": "post",
                    "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/files",
                    "queries": {
                        "folderPath": "/rithwik",
                        "name": "rithblob",
                        "queryParametersSingleEncoded": true
                    }
                },
                "runAfter": {
                    "Initialize_variable": [
                        "Succeeded"
                    ]
                },
                "runtimeConfiguration": {
                    "contentTransfer": {
                        "transferMode": "Chunked"
                    }
                },
                "type": "ApiConnection"
            },
            "Initialize_variable": {
                "inputs": {
                    "variables": [
                        {
                            "name": "var1",
                            "type": "string",
                            "value": " ۝ $\u0011 W$H: A   XPg   k\u0003\u0001v i 8 \u001c  K5u\u0003   G ƥ֋\u001d B p  b  \\  nړ1  $N ;\u000e _x\u0011  /  \u0001\t \u0006\u0003*\u001b-N\u001cP`  @ ,p zOW5 絒 \u001a\u000e' \u0006 \u0004\u000b R\u000e Z p  \u0015 C a\u0017   \f\n ! 6z3  3  \n/ = > \u0005  w@  \u001eX?  \u0017    O  `  & .  _iΓi n     +\u000f  Hj2_\" k +\u000e\f  ç   U  \u0006 sտ\u0013j/  . o : P W O  95  T $ug  \u001fZBm / C\u000e\u0016詷U пb  [\u0011 ʒ\n\u000f E %gW#   -\n AV//gJ' \u0014~  -\u0004 \u0015  \u001c tpi   ͟[qʍi   o  \u001e \u001e ab\u0001["
                        }
                    ]
                },
                "runAfter": {},
                "type": "InitializeVariable"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "manual": {
                "inputs": {
                    "schema": {}
                },
                "kind": "Http",
                "type": "Request"
            }
        }
    },
    "parameters": {
        "$connections": {
            "value": {
                "azureblob_1": {
                    "connectionId": "/subscriptions/b83c1ed3/resourceGroups/vrbojja/providers/Microsoft.Web/connections/azureblob-1",
                    "connectionName": "azureblob-1",
                    "id": "/subscriptions/b83c1ed3/providers/Microsoft.Web/locations/eastus/managedApis/azureblob"
                }
            }
        }
    }
}
RithwikBojja
  • 5,069
  • 2
  • 3
  • 7
0

You can do this:

Create a Logic App that looks like this, meaning that you need to have a storage account and a container where you will store the files

If you do not have a container simply create one

Next as you can see I am sending an email with a PDF attachment from a google account to a outlook one.

And here you can see that I have received it in Outlook

So now the Logic App will run since it expects for emails with attachments, and if you now check your blob container you can see that you have the file there, after downloading it, you will see that it is intact.

Hope this helps, if you need more assistance just let me know. (no reputation points yet, just started to contribute in stack overflow recently so i can only share 8 links, no images if this helped you please upvote it :) )

01

02

03

04

05

06

07

08