Hi,
I'm experiencing some issues with uploading documents in Dynamics 365 (to sharepoint) with the rest web API.
In Dynamics 365, I've configured the integration with SharePoint and it's working fine. Now, i've the requirement to programmatically upload a document for a given entity.
I've seen that from the web apps, to upload a document is called the UploadDocument endpoint:
I've replicated the POST request from postman, but i'm getting two types of results:
- "204 - no content" (success) when sharepoint document location already exists for the target entity
- "500 - Internal server error" when it doesn't exists (whit the generic error "0x80040216 - An unexpected error occurred.")
I'm calling it with a oauth2 token issued for the admin user.
I'm relying on the Dynamics 365 API, instead of sharepoint, because i would like to maintain the same folder nomenclature with the web-uploaded documents (entity name trailing random code), and so let dynamics do all the sharepoint work.
This is a sample of the body of the request I'm sending (empty guid for opportunityid is intended), that's the same body the web app is using:
{ "Content":"cHJvdmEgZG9jdW1lbnRvIHRlc3Rv", "Entity": { "@odata.type":"Microsoft.Dynamics.CRM.sharepointdocument", "locationid":"", "title":"doctest.txt" }, "OverwriteExisting": true, "ParentEntityReference": { "@odata.type": "Microsoft.Dynamics.CRM.opportunity", "opportunityid":"00000000-0000-0000-0000-000000000000" }, "FolderPath": "" }
Bye!