Why is the Graph API response payload size about 1/3 larger than the email attachment size

Andrew Earl 105 Reputation points
2024-08-16T08:05:51.25+00:00

Hi,

When I GET an email's attachments via Graph API using the postman GET call: https://graph.microsoft.com/v1.0/me/messages/{{messageid}}/attachments

the uncompressed size of the payload is consistently about 1/3 larger than the attachment size. E.g.

  • An email with no contents and just a single 1Mb attachment has an uncompressed payload size of 1.33Mb
  • An similar email with just a single 20Mb attachment has an uncompressed payload size of 26.67Mb

Do you know why the payload size is so much larger than the attachment size?

Can I rely on it being 1/3 larger than the attachment size?

The reason is we have an application where users can download attachments to a database via Graph API and I want to set a limit on the size of the attachment that can be downloaded. So if i want to allow up to 10Mb attachments should I check for a payload size up to 13.33Mb?

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

Accepted answer
  1. Vasil Michev 119.5K Reputation points MVP Volunteer Moderator
    2024-08-16T16:56:49.1266667+00:00

    Because of Base64 encoding, as explained for example here: https://learn.microsoft.com/en-us/exchange/mail-flow/message-size-limits?view=exchserver-2019

    Base64 encoding increases the size of the message by approximately 33%, so the value you specify should be approximately 33% larger than the actual message size you want enforced. For example, if you specify a maximum message size value of 64 MB, you can expect a realistic maximum message size of approximately 48 MB.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.