Hi All,
I have a requirement to upload PDF file to sharepoint online in D365FnO. I am using the below code snippet, this snippet is being used in a lot of examples online for uploading the PDF file to share point.
I am giving an external id that is working. The sharepoint link given in the document management parameters are validated successfully. I do not see any issue on the setup.
But when running the below piece of code, I get an error at the line storageProvider.SaveFile

externalId = xUserInfo::getExternalId("XXX.YY");
//externalId = "10033FFFAE505117";
System.Byte[] value = this.runAndSaveSSRSReport();
System.IO.MemoryStream stream = new System.IO.MemoryStream(value);
// System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(System.Convert::FromBase64String(value));
// Instantiate SharePoint document storage provider with sharepoint address path.
Microsoft.Dynamics.AX.Framework.FileManagement.IDocumentStorageProvider storageProvider = new Microsoft.Dynamics.AX.Framework.FileManagement.SharePointDocumentStorageProvider(
defaultSPServer,
spSite,
spFolderPath,
externalId);
storageProvider.ProviderId = DocuStorageProviderType::SharePoint;
if (storageProvider != null)
{
// Generates a unique file name in case the file name already exists on SharePoint path.
// str uniqueFilename = storageProvider.GenerateUniqueName(filename);
// Upload file to SharePoint Online path.
Microsoft.Dynamics.AX.Framework.FileManagement.DocumentLocation location = storageProvider.SaveFile(
newGuid(),
FileName,
fileContetType,
stream);
Is there some configuration I am missing? Will be very helpful if someone can shed light on this,
Thanks in advance
Sabarish