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
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
2) Step 2 I retrieved Parent Id
3) Step 3
I am trying to create attachment
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", "parentType": "Sales Order"}
Request is successful and I get Id for attachment
4)Step 4
Everything is ready for PATCH method via /companies(CompanyId)/attachments(IncomingDocumentId)/attachmentContent
I am using the following code
In this part user and password are client id and client secret for Oauth authentication
BaseAddress is "api.businesscentral.dynamics.com/.default"
Authorization parameter is Bearer - oauth token
URl is following
The request did not failed
but unfortunately the attachment is not present in the system, only Sales Order fields are present