File Upload to Sharepoint from Business Central SAAS using REST API – Part II

Hello Readers, 

 

I hope you got some idea how to configure the Sharepoint site for Business Central, in continuation to my last blog, we will write code into Business Central using REST API, which will upload the file into Sharepoint Shared Documents folder. 

This can be achieved by performing the below steps:

1. Authentication using Bearer Token

2. Configuring the API for uploading the file.

Pre-Requsite required.

This we have already generated in my last blog.

1. TokenURL: Label ‘https://accounts.accesscontrol.windows.net/YourTenantID/tokens/OAuth/2’;
2. ClientId: Label ‘7*9b78fd-8c24-4b*c-971a-3a1**87bbb0d@YourTenantID’;
3. ClientSecret: Label ‘WUPp**ZwhSLP0Y49xZAiMmTzJX*J80nBQDUvwrMZQSo=’;
4. Resource: Label ‘00000003-0000-0ff1-ce00-000000000000/YoursharepointDomain.sharepoint.com@YourTenantID’;
 
1. Create a Codeunit for Sharepoint API configuration, 
and add the below function for authentication as below.
 
 
 
 
 
Above function will return the Bearer token as below:
 
 
 
 
2. Now, create a new function for uploading a file into Sharepoint as below.
 
 
 
 
3. Create a page extension of page “Document Attachment Details” and add a page action as below.
 
 
 
Save all the files and publish the code into Business Central.
 
 
Now it’s time to test the functionality:
 
1. Login to the Business Central, Navigate to Purchase Order or any Standard document page,
and open the Document attachment detail from the factobox.
2. Click on the Attachment column and upload a file, and then select the line
 and click on the “Upload File to Sharepoint” button.
3. The below link will get populated and the file will get uploaded to the sharepoint. 
4. By clicking the link column it will navigate, you to sharepoint file directly from Business Central.
 
 
 
I hope you get good amount of understanding on how to work with the uploading file from Business Central
to Sharepoint.
Please write me if you have any queries, or any topics you want me to write in the next blog.
 
will be back with another topic, till then good bye take care.



  

Thank you,

Anish Agrawal

NAV/Business Central Developer

Connect me on : +91-9770757595

Linkedin :Anish Agrawal 

 

Leave a Reply

Your email address will not be published. Required fields are marked *