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

Upload attachment using API (OData)

(0) ShareShare
ReportReport
Posted on by

Hi,

I'm trying to understand how to upload file (as attachment) to D365FO via OData API. Is it possible?
I saw quite a lot questions about this but didn't find an answer.

Just to be clear, an example:
There is a Purchase Order in the D365FO. I want to add attachment to it via API. How should I do it? Is there any code examples?

If it is not possible to do via OData, is there any other ways for external services (for example, simple console application) to do it?

Also, I saw info about Recurring Integration. Not sure that is what I want.

Thanks!

I have the same question (0)
  • WillWU Profile Picture
    22,361 on at

    Hi Androsik Vladimir,

    How do you want to upload the attachment, you could use file upload control to upload attachment , please check the FileUploadTemporaryStorageStrategy.uploadFile() method, it will upload files to the temporary blob storage and you could use FileUploadTemporaryStorageResult class to get a download url.

  • Community Member Profile Picture
    on at

    Hi Will Wi,

    Blob storage is ok. But is it possible to do via REST API? Without using AX framework?

    Just to be clear: Let's say, I want to create new Purchase Order.

    So, I'll send request like:

    Method: POST

    URL: https://{baseUrl}/data/PurchaseOrderHeaders

    Body:

    {

    // some data

    }

    If I entered all the data correctly, the order will be created.

    Can I do something similar to add an attachment to this order?

    I saw this post: https://community.dynamics.com/365/financeandoperations/f/dynamics-365-for-finance-and-operations-forum/373447/uploading-attachment-to-current-record-in-dynamics-f-o-with-the-use-of-odataultility-library-c
    There author is trying to do something very-very similar to what I want. But, honestly, I can't understand completely how to do it for Purchase Orders.

  • Suggested answer
    dan.richo Profile Picture
    14 on at

    Yes, after you have created the header then use the following

    URL: https://{baseUrl}/data/PurchaseOrderHeaderDocumentAttachments

    body:

    {
       "FileName": "VelradLogo",
       "dataAreaId": "vel",
       "DocumentAttachmentTypeCode": "File",
       "FileType": "png",
       "PurchaseOrderNumber": "VEL-000021",
       "Notes": "Velrad Logo",
       "Attachment": " -- base64 of attachment goes here --- "
    }

    pastedimage1636432192868v1.png

  • Dong Luo Profile Picture
    35 on at

    PurchaseOrderHeaders and PurchaseOrderHeaderDocumentAttachments work for Purchase Order.

    How about Purchase Requisition and Purchase Agreement?

    PurchaseRequisitionHeaders and PurchaseAgreements are available, but I cannot find the attachment APIs for them.

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