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 Learn
Depending on the API call that I use, this either looks something like this:
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.
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.