web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

I need a way to download an attachment without being logged into dynamics.

(0) ShareShare
ReportReport
Posted on by

Hello,

We need to be able to download attachements hosted in dynamics from a third party website.

So far, we are using a custom REST API that will return the needed information using the following:

DocumentManagement::getAttachmentPublicUrl(docuRef)

And that work, this gets me the url and the accesstoken needed to download the file. However, this works only if we are logged into Dynamics, that is to say, of course throught the UI or with Swagger for example. But if I get the link from the other website, or even PostMan, calling my custom REST API, I get a 404.

I noticed that the access token returned with DocumentManagement::getAttachmentPublicUrl(docuRef) includes a UserId among other information. It seems to me that this UserId is set to the Partition when the call is not made from a logged user. Hence the 404.

Would you think of something that I could try? Is the approach wrong. 

Thanks for any insight. 

I have the same question (0)
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    301,020 Super User 2025 Season 2 on at

    Hi Happouh,

    There is no option to access data without authentication and authorization. If you want to share files, you have to copy them into a public area. Dynamics 365 will never allow public access; also not for attachments. You might have attachments with sensitive information which needs to be protected.

  • Happouh Profile Picture
    on at

    Hello André,

    Thanks for your response.

    I failed to mention that we are using an access token generated by Azure when we call the REST API. So we have authorisation. The rest of the info regarding the attachements are sent properly, e.g. Name,  type and so on.

    However, the token generated in the url of the attachment itself also contains a token that is not letting us in.

    In short, from a non logged user, I can get a url of the attachement, but that url is not usable. I hope that this clarifies my question.

    Thanks

  • André Arnaud de Calavon Profile Picture
    301,020 Super User 2025 Season 2 on at

    Hi Happouh,

    You might have a link like this one:  

    [Dynamics365 URL]/filemanagement/[GUID]/display?access_token=[Access token]&ms-dyn-caid=[GUID]

    This is a service which is requiring user authentication to get the contents of the attachment.

  • Happouh Profile Picture
    on at

    Hi,

    Yes, that is the link I get.

    Your answer makes me wonder why I can get the other information (including this url) using the azure token but not the attachments itself. to me, its all data.

    Would there be a way to use impersonation?

    What is the use of the accesstoken included in the url then?

    Is there another service that can be used?

    Sorry for those many questions. Thanks for your help.

  • André Arnaud de Calavon Profile Picture
    301,020 Super User 2025 Season 2 on at

    Hi Happouh,

    I don't have that experience. Can you tell how you got the other information?

  • Happouh Profile Picture
    on at

    Hi,

    We actually have a Token that we get from Azure, we send to Azure the client_id, the client_secret and it returns a token. That token allows us to call our api and get the answer. Sorry if I was missleading. Here is a link that will explain with some diffrences how this works: https://medium.com/capgemini-microsoft-team/access-tokens-for-dynamics-365-using-microsoft-authentication-library-2b16c9f794b. In our case however, we use the following to get the token once things are setup: login.microsoftonline.com/.../token

    Then in the answer, we get the url that also has a token but it is not working when the user is not logged into Dynamics. 

    Thanks,

    Gérald

  • André Arnaud de Calavon Profile Picture
    301,020 Super User 2025 Season 2 on at

    Hi Happouh,

    The link you provided is for Dynamics 365 "CRM". However, there is a similar option for F&O. I do think the image URL is opening a webservice which is separate from the Dynamics ERP permissions. You might contact Microsoft Support for some more clarity.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans