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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

The record in table Unlinked Attachment already exists. Identification fields and values: Id='{00000000-0000-0000-0000-000000000000}

(0) ShareShare
ReportReport
Posted on by 130

For creating sales orders attachment I used following request

https://api.businesscentral.dynamics.com/v2.0/<tenantID>/uat/api/v1.0/companies(companyID)/attachments

Body:

{    “parentId”: “5a086bc7-195f-eb11-89f9-0022481ab2d5”,    “fileName”: “Example.pdf”}

At first time it worked and generated Id for attachment, but my PATCH request was failed

PATCH businesscentralPrefix/companies({companyId})/attachments(parentId={parentId},id={attachmentId})/content 

I tried to do first request again as I did not saved parentId and now it throws such error : "{\"error\":{\"code\":\"Internal_EntityWithSameKeyExists\",\"message\":\"The record in table Unlinked Attachment already exists. Identification fields and values: Id='{00000000-0000-0000-0000-000000000000}'  CorrelationId:  e6964edd-e341-4da2-804d-534c1ea681e3.\"}}"

It was advised to retrieve the parent Id from the first successful attachment creation and use that parent Id in the PATCH request instead of creating a new one, but how to retrieve that parentid ? what request should be used ?

Thanks in advance 

I have the same question (0)
  • Suggested answer
    Marco Mels Profile Picture
    Microsoft Employee on at

    Hello,

    You first create the name of the attachment and then you need to fill it with data via /attachmentContent.

    api.businesscentral.dynamics.com/.../attachmentContent

    Hope it helps.

  • Dynamics Questions Profile Picture
    130 on at

     Hi Marco Mels ,

    You  have described, what I have already done.

    I have done similar steps as it is provided in official documenation https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/api-reference/v2.0/api/dynamics_attachment_update

    I am receiving error : 

    The record in table Unlinked Attachment already exists. Identification fields and values: Id='{00000000-0000-0000-0000-000000000000}

    when attempting to perform this request 

    pastedimage1677750909298v1.png

  • Suggested answer
    Amit Profile Picture
    2,561 on at

    Hello,

    First do it manually and understand the system and then write logic accordingly.

    Regards

    Amit Sharma

    www.erpconsultors.com

  • Dynamics Questions Profile Picture
    130 on at

    How I can understand if there is no clear instraction for this ? All that I have are bare requests and errors

  • Dynamics Questions Profile Picture
    130 on at

    How I can understand if there is no clear instruction for this ? All that I have are bare requests and errors

  • Suggested answer
    Jeremy Vyska Profile Picture
    727 on at

    I (and a couple of coauthors) recently wrote a book on the API's, and the Attachments topic was definitely a chapter that was worth writing up.

    It sounds like you're already on the right track.

    What happens in the flow of creating an Incoming Document is that you:

    - POST to create an Incoming Document record entry /attachment

    - PATCH the Incoming Document entry to have the new /attachmentContent

    The body of the POST needs to contain:

    - parentType ("Sales Order" for example)

    - parentId (the Guid of a Sales Order)

    - fileName ("Example PDF")

    This will reply with a POST Response that will contain the new Id field of the Incoming Document.

    You then do a PATCH call to that Incoming Document, via /companies(CompanyId)/attachments(IncomingDocumentId)/attachmentContent

    What it sounds like you're experiencing is that the Incoming Document was created with a Null Guid in a table for "Attachments" that aren't linked to a Document.  When subsequent calls are being made, it's trying to make another null guid entry, and that's stopping you.

    Two things will help:

    - Run page 199 directly (add ?page=199) and remove the Unlinked Attachment

    - If your POST call attaches the Document to a Document correctly, then you'll also not hit this table, saving you from errors.

    Hope this helps - the API v2.0 reference book has gotten quite some praise for our coverage of Attachments and such.

  • Dynamics Questions Profile Picture
    130 on at

    Hi Jeremy Vyska 

    Hi,

    Thank you for the explanation

    I need assistance with this part : " Run page 199 directly (add ?page=199) and remove the Unlinked Attachment". This is exactly what I need to do.

    However when I am trying to type page in browser 199, I am still redirected to Sales Orders

    pastedimage1678233317188v1.png

    this is my url : https://businesscentral.dynamics.com/?company=CRONUS%20Canada%2C%20Inc.&node=0000233e-0d57-0000-0c65-1900836bd2d2?page=199

    What I am doing wrong ?

  • Jeremy Vyska Profile Picture
    727 on at

    Hmm, looks like Page 199 was marked "Non editable" anyway.

    See if the 'hiding' attachment is available in this page?

    https://businesscentral.dynamics.com/?page=2820

  • Dynamics Questions Profile Picture
    130 on at

    There is nothing 

    pastedimage1678280509533v1.png

  • Dynamics Questions Profile Picture
    130 on at

    There is nothing 

    pastedimage1678280544783v2.png

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,958 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,101 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 959 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans