Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Upload pdf files as attachment documents to Business Central Items using OData Api V4 web services

(0) ShareShare
ReportReport
Posted on by 15

Hello,

I am looking for an OData web service that allows me to upload a pdf document to an Item in Business Central. I was able to get information on documents attached (uploaded from front end) using the below web service:

GET {{BaseURL}}/{{environment}}/AttachedDocuments

Now i need to basically attach or upload document to a specific Item using web services. I have tried several tables and web services but in vain. 

Kindly guide me on how i can achieve this using OData web v4 services.

Thanks.

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Upload pdf files as attachment documents to Business Central Items using OData Api V4 web services

    Hi,

    I will suggest create a New API page and use that API page to insert the attachment and move those attachment to further to other your required table.

    for more info. please refer below link

    https://accelerationeconomy.com/news/demo-business-central-api-for-importing-exporting-attachment/

    Thanks.

  • sina123 Profile Picture
    sina123 15 on at
    RE: Upload pdf files as attachment documents to Business Central Items using OData Api V4 web services

    Hi, I tried the suggestion but get an error "Entity does not support insert" while sending a POST to /ImportItem endpoint created using tableid 348 Import Item Pictures.

  • Suggested answer
    divyeshchitte Profile Picture
    divyeshchitte 950 on at
    RE: Upload pdf files as attachment documents to Business Central Items using OData Api V4 web services

    HI Sina,

    You can use base functionality of Microsoft, which is available on Inventory setup page> Import Item.

    You can create a publish an API page for "Import Item Pictures" Page id 348 and then upload the items through API.

  • Suggested answer
    Marco Mels Profile Picture
    Marco Mels on at
    RE: Upload pdf files as attachment documents to Business Central Items using OData Api V4 web services

    Hello,

    If you run this command in Postman:

    api.businesscentral.dynamics.com/.../items eq '1896-S'

    This is for ATHENE Tafel in demo data, you get the following:

    {

       "@odata.context": "<<REMOVED>>/items",

       "value": [

           {

               "@odata.etag": "W/\"JzIwOzEyNjE3ODgwMjUzNzkzNDc1MjExMTswMDsn\"",

               "id": "4d5de349-0fe2-ec11-bb45-000d3a39a433",

               "number": "1896-S",

               "displayName": "ATHENE Tafel",

               "type": "Inventory",

               "itemCategoryId": "3304de4f-0fe2-ec11-bb45-000d3a39a433",

               "itemCategoryCode": "TAFEL",

               "blocked": false,

               "gtin": "",

               "inventory": 4,

               "unitPrice": 1005.8,

               "priceIncludesTax": false,

               "unitCost": 784.6,

               "taxGroupId": "00000000-0000-0000-0000-000000000000",

               "taxGroupCode": "",

               "baseUnitOfMeasureId": "d05de349-0fe2-ec11-bb45-000d3a39a433",

               "baseUnitOfMeasureCode": "STUKS",

               "generalProductPostingGroupId": "0d02de4f-0fe2-ec11-bb45-000d3a39a433",

               "generalProductPostingGroupCode": "DET.HANDEL",

               "inventoryPostingGroupId": "bd5de349-0fe2-ec11-bb45-000d3a39a433",

               "inventoryPostingGroupCode": "WEDERVERK",

               "lastModifiedDateTime": "2022-06-16T07:08:14.613Z"

           }

       ]

    }

    There is no attachment field you can use; therefore you must create a custom API.

    Thanks.

  • sina123 Profile Picture
    sina123 15 on at
    RE: Upload pdf files as attachment documents to Business Central Items using OData Api V4 web services

    Thanks for the response, but the documentation is regarding attachments for journallines but i need to attach document to an Item. I have tried the request but doesnt work for an item unfortunately.

  • Suggested answer
    Marco Mels Profile Picture
    Marco Mels on at
    RE: Upload pdf files as attachment documents to Business Central Items using OData Api V4 web services

    Hello,

    Hope this helps:

    docs.microsoft.com/.../dynamics_attachment_update

    Thanks.

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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans