cancel
Showing results for 
Search instead for 
Did you mean: 

Downloading a file from Sharepoint

anmaheswa
Level 4
How to download a file using the sharepoint url. I am aware of the mapping Sharepoint to explorer option however that won't work in my case. I tried using File management utility and download File action but it pops up with the forbidden error message. However it's not due to access, as manually I am able to perform the same operation.

------------------------------
Ankita Karnany
Principal Consultant
Agilisys
London
------------------------------
10 REPLIES 10

Hi Ankita,

Have you tried using the Graph API based Sharepoint asset available on DX https://digitalexchange.blueprism.com/dx/entry/3439/solution/microsoft-graph-api---sharepoint. There is an action available in it that downloads file.

------------------------------
Shashank Kumar
DX Integrations Partner Consultant
Blue Prism
Singapore
+6581326707
------------------------------

Hi Shashank,

Seems like the asset doesn't exist..

5903.png

------------------------------
Ankita Karnany
Principal Consultant
Agilisys
London
------------------------------

Hi Ankita,

Can you try this link https://digitalexchange.blueprism.com/dx/entry/3439/solution/microsoft-graph-api---sharepoint

------------------------------
Shashank Kumar
DX Integrations Partner Consultant
Blue Prism
Singapore
+6581326707
------------------------------

Hey Shashank,

I have managed to download the API, however could you also help with the parameters I need to pass . I haven't used it earlier so not aware on how we can use this.

5905.png

------------------------------
Ankita Karnany
Principal Consultant
Agilisys
London
------------------------------

Hi @anmaheswa,

There's a new VBO that should be published to the DX early next week. It's called Microsoft Graph - Dowload Files. The VBO provides a simplified means of downloading files from various Microsoft resources including SharePoint, OneDrive, Group drives, User drives, and Pre-Authenticated URLs.

The Download File action on the Microsoft Graph - SharePoint connector may or may not work for you. The issue is that the connector is built using the Web API feature of Blue Prism and that feature doesn't like downloading files that contain binary content (ex. PDFs). That's why we create the new VBO. It can handle binary files as expected.

If the file you're trying to download from SharePoint is a regular text file, the Download File action will work find. There are a few things you need to understand though in order to use the Microsoft Graph assets:

  1. You also need to use the Microsoft Graph - Authentication VBO. You can find that here. This VBO is used to request an access token from Microsoft. You need to keep track of that token and pass it in as an input parameter to most of the other Microsoft Graph connectors.
  2. To use the Authentication VBO you need a few things:
    1. You need to know your Tenant ID on Microsoft 365. Your tenant ID has two forms: You domain or a GUID. Here are some examples: contoso.onmicrosoft.com or 471d90aa-6db9-4a11-9479-799d3a8d7547 
    2. You'll also need a Client ID and Client Secret (for an Application Access token). If you want a Delegated Access token you'll need a Client ID, Client Secret and the username and password of the user account you're trying work on behalf of. There's information about this in the Microsoft Graph - Authentication VBOs user guide.
  3. Once you have the Authentication VBO sorted and you're able to issue a successful request for a token you'll be ready to work with SharePoint connector. At this point you need to know the Site ID, Drive ID, and File ID of the specific file you want to download. These ID's are unique alphanumeric identifiers. You can get them by working through some of the other actions available on the SharePoint connection (namely the Get and List operations) to see the details of items within the SharePoint site. Alternatively, you could try using Microsoft's Graph Explorer utility to get that information.

    Graph Explorer is a web-based utility for testing the various Graph endpoints.
I know all of that sounds like a lot and to a certain extent it is. Once you start working with Graph things start to make sense though. Now, if you're in a hurry and you have access to the direct download URL for a file on SharePoint, you can use the Utility - HTTP VBO to download the file. Just make sure you get the latest version of that VBO from the Digital Exchange.

That VBO has a action called HTTP Request File. You can pass in your URL, set the Method to GET, enter the FilePath (where you want to file saved to), and you should be good to go. That is assuming the URL you have doesn't require authentication.

Cheers,

------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

Thanks a lot Eric for the detailed information you have provided. Let me give it a a go and I shall get back to you in case of any concerns. Appreciate your help on this.

------------------------------
Ankita Karnany
Principal Consultant
Agilisys
London
------------------------------

I have a direct download URL of SharePoint but it needs authentication.

My link is : https://spanet.sharepoint.com/sites/TOC/Lists/OMS%20%20Application%20Data/Attachments/954/VA-21841.pdf

What do I need to do to download directly from the download URL using  Utility - HTTP VBO?

I tried Utility - HTTP but got a 404 Unauthorized error.

How to pass the authentication?

5916.png



------------------------------
Abhirup Das
------------------------------

Looks like the user doesn't have the necessary permissions to download the file.

Please check the permissions in the Azure portal

5919.png

https://learn.microsoft.com/en-us/graph/api/driveitem-get-content?view=graph-rest-1.0&tabs=http 



------------------------------
Shashank Kumar
DX Integrations Partner Consultant
Blue Prism
Singapore
+6581326707
------------------------------

I check the permission is given.

The Action Properties are following :

5923.png

Can you please guide me what I'm doing wrong?



------------------------------
Abhirup Das
------------------------------