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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

c# Business Central How to Attach Documents Oauth. Error : 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

Hi,

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.\"}}"

How can I fix it ? As I understand parentId that was generated previously must be utilized but how ?

I have the same question (0)
  • s.sheikh Profile Picture
    20 on at
    [quote user="Dynamics Questions"]

    Hi,

    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.\"}}"

    How can I fix it ? As I understand parentId that was generated previously must be utilized but how ?

    [/quote]


    From what I know, 

    To fix this issue, you must utilize the parent Id that was generated previously.

    To do this, follow these steps:

    1. Retrieve the parent Id from the first successful attachment creation.
    2. Use that parent Id in the PATCH request instead of creating a new one.
    3. Ensure that the parent Id, company Id, and attachment Id values in the PATCH request are correct and correspond to the existing attachment.
    4. check if there is any issue with the request header or body you are sending for patch request.
    5. Verify that the user has the necessary permissions to update the attachment.

    By following these steps, you should be able to update the attachment successfully without encountering the same error message.

  • Dynamics Questions Profile Picture
    130 on at

    Hi 

    Thank you for the quick response

    How to perform the first step - Retrieve the parent Id from the first successful attachment creation. ?

    What request should be used for this ?

  • Dynamics Questions Profile Picture
    130 on at

    s.sheikh 

    Please provide a reference for guide or  code samples

    How to form request for the first step ?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 647 Super User 2026 Season 1

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 447 Most Valuable Professional

#3
YUN ZHU Profile Picture

YUN ZHU 366 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans