Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Sales forum / How to programmaticall...
Sales forum
Answered

How to programmatically download attachments in notes

Posted on by 50

Does anyone know how to pragmatically download attachments from Opportunity notes? I have been able to download and upload to SharePoint any EMBEDDED attachments stored in msdyn_fileblob, but if it is a direct attachment stored in annotations documentbody, it is not in the same file format. I am not familiar with how to convert this into a text/plain fileblob format I can upload to sharepoint.

Working on a script to migrate all notes to SharePoint and update opportunities with hyperlink to document (space savings).

Categories:
  • Verified answer
    Levi Stevens Profile Picture
    Levi Stevens 50 on at
    RE: How to programmatically download attachments in notes

    Solutions was following:

    $fileblob = [System.Convert]::FromBase64String($documentbody)

    $upload = Call-WebAPI -URI "$mgurl/drives/$PDR_RootID/root:/$locationurl/$($fileName):/content" -Method PUT -Accept "text/plain" -Authorization $Token2 -Body $fileblob -ContentType 'text/plain'

    Using the content type 'text/plain'.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,339 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,177 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans