Hi Mohit,
I used below code to read the file.
public System.IO.MemoryStream getFileStreamFromSharepoint()
{
#File
#define.https("https://")
#define.decodeUrl("/_api/Web/GetFileByServerRelativePath(decodedurl='/")
fileName = SOCreates+ #xlsx;
System.Uri uri = new System.Uri(#https + host + #decodeUrl + site + "/" + folderPath + "/" + fileName + "')");
//I throw away the part assuming that proxy is populated, because it can't ever be - we're initializing it here.
ISharePointProxy proxy = SharePointHelper::createProxy(host, site, externalId);
FileResults fileResults = SharePointHelper::GetFiles(proxy, FolderPath, ''); // The file result is returned successfully
FileContents file = SharePointHelper::GetFileContents(proxy, uri); //This line returns a null value and no exception or error
if(file)
{
System.IO.Stream fileStream = file.content;
System.IO.MemoryStream ms = new System.IO.MemoryStream();
fileStream.copyTo(ms);
return ms;
}
else
{
return null;
}
}
I have hard coded the file name to fetch the file and read its work for 1 file but how can I get all file names which are there on SharePoint folder and read the files ?
I want loop all the files which are there on SharePoint folder read the files and create sales order in D365FO.
I'm running a batch Job in Dynamics365FO which will read all the files that are available on the SharePoint folder and create sales order.
