none
download an attachment from office365 rest api knowing only the attachmentItemID RRS feed

  • Question

  • Drag and dropping a file from a browser logged into office365/outlook gives me a JSON string with the attachmentItemId but not the message ID.

    attachmentV{"itemType":"attachment","attachmentFile":{"attachmentItemId":"AAMkADhmNz......","name":"feb invoices archive.pdf","size":64276,"fileType":5,"type":"ItemIdAttachment:#Exchange"}}
    

    Yet the only endpoints I can see for fetching an attachment require the messageID.

    e.g. GET https://outlook.office.com/api/v2.0/me/messages/{message_id}/attachments/{attachment_id}

    Is there a way to download an attachment without knowing the message id?

    Tuesday, March 31, 2020 1:02 PM

All replies

  • best i could find so far is to search messages for the file name

    .../messages/?$search="attachment:{Name}"&$expand=Attachments

    and then loop through the returned messages and their attachments looking for the specific id.

    not ideal... but it's working.

    n.b. you have to replace any "/" characters with "-" and any "+" with "_" in the attachmentid when comparing with the id returned in the search.

    Saturday, April 4, 2020 7:24 PM