cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
X1ng
Microsoft
Microsoft

Cannot parse content bytes from blob correctly

Hi all, I am building a flow with azure blob storage and outlook email. Firstly, I get the content of a blob from storage account; it should be a json file, and it contains an attachment array:

"AttachmentsPower": {
            "type""array",
            "items": {
                "type""object",
                "properties": {
                    "Name": {
                        "type""string"
                    },
                    "ContentBytes": {
                        "type""string"
                    }
                },
                "required": [
                    "Name",
                    "ContentBytes"
                ]
            }
        }

Then I try to set it as attachment of my email, the whole flow is like this:

X1ng_0-1653466355499.png

However, I found the attachment sent in the email is not the same as the original one. For examle, I uploaded a test.txt to blob and it content is "test test test范德萨发大水"; while I got a test.txt from email whose content is "dGVzdCB0ZXN0IHRlc3TojIPlvrfokKjlj5HlpKfmsLQ=". I am guessing I need to do some decode but I don't know how to do it. I searched a lot but found no result. Could anyone please help me out?

 

1 ACCEPTED SOLUTION

Accepted Solutions
ashyriverflow
Resolver II
Resolver II

Hi @X1ng , in the Flow run, what is the returned value of ContentBytes in the Get Blob Entity action?

If it's also "dGVzdCB0ZXN0IHRlc3TojIPlvrfokKjlj5HlpKfmsLQ=", then base64tostring() is needed but only for the ContentBytes property, not the whole AttachmentsPower.

You might need to reconstruct AttachmentsPower object with the new decoded - this one is a bit tricky though.

View solution in original post

4 REPLIES 4
ashyriverflow
Resolver II
Resolver II

Hi @X1ng , the action Get blob content (V2) is able to get the content of a text file without the need of decoding it.

ashyriverflow_0-1653469328097.png

Can you explain more what you meant by "it should be a json file..."?

Hi @ashyriverflow, thanks for answering. The content of the blob file is a json file:

{
    "type""object",
    "properties": {
        "BodyPower": {
            "type""string"
        },
        "AttachmentsPower": {
            "type""array",
            "items": {
                "type""object",
                "properties": {
                    "Name": {
                        "type""string"
                    },
                    "ContentBytes": {
                        "type""string"
                    }
                },
                "required": [
                    "Name",
                    "ContentBytes"
                ]
            }
        }
    }
}

It has two fields, bodyPower and attachmentsPower. The body Power is text for email body, and it works well now. However, attachmentsPower is an array, and has two fields for each element -- Name and ContentBytes (which are consistent with attachement array for email). It could have several different type of files, such as .txt, .png, .tsv, etc.. If I directly use the array in email connector:

X1ng_0-1653472424243.png

The files I received from email are not correct. That's why I am thinking maybe I need to decode them or something.

 

ashyriverflow
Resolver II
Resolver II

Hi @X1ng , in the Flow run, what is the returned value of ContentBytes in the Get Blob Entity action?

If it's also "dGVzdCB0ZXN0IHRlc3TojIPlvrfokKjlj5HlpKfmsLQ=", then base64tostring() is needed but only for the ContentBytes property, not the whole AttachmentsPower.

You might need to reconstruct AttachmentsPower object with the new decoded - this one is a bit tricky though.

Thanks, @ashyriverflow.

I decoded the ContentBytes and it works.

The additional part of flow is like this:

X1ng_0-1653486003653.png

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (2,304)