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

Community site session details

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

The number of keys specified in the URI does not match number of key properties for the resource 'Microsoft.NAV.attachment'

(0) ShareShare
ReportReport
Posted on by 130

Hi, 

I am trying to implement adding attachments to Business Central via Oauth

Maybe I am doing something wrong, please, look at my steps.

1)POST to create an Incoming Document record entry /attachment

Image

where _connectionDynamicsBusinessCentralOptions.Scope value is "">api.businesscentral.dynamics.com/.default"

URL is /v2.0/fc586214-b714-4bc4-8ff8-2e13a1a007cd/Sandbox/api/v2.0/companies(51fafb6c-c141-ec11-bb7e-000d3abb14eb)/salesOrders

BODY is {"externalDocumentNumber":"finally","currencyCode":"EUR","customerNumber":"10000","orderDate":"2023-08-05"}

The request is successful and data already generated in dynamics' system 

Image

2) Step 2 I retrieved Parent Id

Image

3) Step 3

I am trying to create attachment

Image

URL is  /v2.0/fc586214-b714-4bc4-8ff8-2e13a1a007cd/Sandbox/api/v2.0/companies(51fafb6c-c141-ec11-bb7e-000d3abb14eb)/attachments

BODY is  {"parentId":"5157829e-b5bd-ed11-9a88-002248d5380a","fileName":"123.txt"}

Request is successful and I get Id for attachment 

Image

4)Step 4

Everything is ready for PATCH method  via /companies(CompanyId)/attachments(IncomingDocumentId)/attachmentContent

I am using the following code

Image

In this part user and password are client id and client secret for Oauth authentication

Image

 BaseAddress is "api.businesscentral.dynamics.com/.default"

Image

Authorization parameter is Bearer  - oauth token 

Image

URl is following

 Image

And I get this

 pastedimage1678287320559v1.png

What I am doing wrong at that part ?

I have the same question (0)
  • Suggested answer
    Marco Mels Profile Picture
    on at
    RE: The number of keys specified in the URI does not match number of key properties for the resource 'Microsoft.NAV.attachment'

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist. If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    www.dynamicsuser.net/.../14

    I will open this up to the community in case they have something to add.

    Thanks.

  • Suggested answer
    DAnny3211 Profile Picture
    11,397 on at
    RE: The number of keys specified in the URI does not match number of key properties for the resource 'Microsoft.NAV.attachment'

    hi

    This error message typically occurs when there is a mismatch between the number of keys specified in the URI and the number of key properties defined for the resource in Microsoft Business Central.

    In this case, it seems that the error is related to the "Microsoft.NAV.attachment" resource. The error message is indicating that the number of keys specified in the URI does not match the number of key properties defined for the attachment resource.

    To resolve this issue, you will need to check the URI and the key properties for the attachment resource to ensure that they match.

    Here are some steps you can follow to troubleshoot this issue:

    Check the URI: Make sure that the URI you are using to access the attachment resource is correct and matches the format specified in the Business Central API documentation.

    Check the key properties: Check the key properties defined for the attachment resource in Business Central to ensure that they match the keys specified in the URI. You can do this by reviewing the metadata for the attachment resource in Business Central.

    Update the URI or key properties: If you find a mismatch between the URI and the key properties, you will need to update either the URI or the key properties to ensure that they match.

    Test the API call: After updating the URI or key properties, test the API call again to see if the issue has been resolved.

    If you are still experiencing issues after following these steps, you may need to seek additional support from a Microsoft Dynamics partner or support team.

    DAniele

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,377

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,696 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,512 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans