Decoding Excel file returned from MS Graph API as Content Bytes

I have a connection to my organization’s mailbox. Using the MS Graph API, the response from the API returns the given message’s attachment (which originally is a .xlsx file) as content bytes. I use the following documentation: Get attachment - Microsoft Graph v1.0 | Microsoft Docs

Depending on the API call that I use, this either looks something like this:

UEsDBAoAAAAAAHZXRlMb8/ygFgAAABYAAAGVzdC50eHR0aGlzIGlzIHNvbWUgdGVzdCB0ZXh0UEsBAj8ACgAAAAAAdldGUxvz/KAWAAAAFgAAAAgAJAAAAAAAAAAgAAAAAAAAAHRlc3QudHh0CgAgAAAAAAABABgAv57iEEW61wG/nuIQRbrXAcZ34hBFutcBUEsFBgAAAAABAAEAWgAAADwAAAAAAA==

Or like this:

image

I tried decoding it as base64, but I get an error that it contains non-base 64 characters, more than two padding characters or an illegal character among the padding characters. I would like to turn the result into a .xlsx file.

Hi @eefzter,

If you are reading the value from an annotation document, you should pay attention to the encoding settings while reading.

image

Specify an encoding while reading. The link below may help you.

Regards,
MY

Thanks @muhammedyuzuak

I have found the solution that I was looking for. The API call needs to return the attachment in this format:
UEsDBAoAAAAAAHZXRlMb8/ygFgAAABYAAAGVzdC50eHR0aGlzIGlzIHNvbWUgdGVzdCB0ZXh0UEsBAj8ACgAAAAAAdldGUxvz/KAWAAAAFgAAAAgAJAAAAAAAAAAgAAAAAAAAAHRlc3QudHh0CgAgAAAAAAABABgAv57iEEW61wG/nuIQRbrXAcZ34hBFutcBUEsFBgAAAAABAAEAWgAAADwAAAAAAA==

I need to put this result into a string and decode it based on Base64, explained below. This helps me convert and save it to a .xlsx file.

Convert Base64 string to Image - Help / Studio - UiPath Community Forum

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.