cancel
Showing results for 
Search instead for 
Did you mean: 

Downloading file from SharePoint

NupurSood
Level 5
Hello All 

I am attempting to access a file from Sharepoint. In this scenario, mapping the Sharepoint site to local network drive is not an option and hence I am leveraging the Graph API. I am unable to convert the response from the download file action to the actual file format. I would great appreciate assistance wrt the same or any suitable alternate approach

Thank You

------------------------------
Nupur Sood
Research Associate
S&P
Asia/Kolkata
------------------------------
11 REPLIES 11

ewilson
Staff
Staff
Hi @NupurSood,

I'm guessing this is tied to an issue with the Web API services feature that limits it to only handling text-base files properly. To get around this limitation you could use the Utility - HTTP VBO for this one action. If you look at the definition of the Microsoft Graph - Sharepoint Web API service you can see the definition of the Download File action basically boils down to a call to ​the following URL:

https://graph.microsoft.com/v1.0/sites/[SiteId]/drives/[DriveId]/items/[File ItemId]/content

So, if you set the following values on the HTTP VBO's HTTP Request File action I think you'll be good:
  • Set the Address input to the above URL (make sure to enter values for variables SiteId, DriveId, and File ItemId in the URL).
  • Set the Use Bearer Token input to True.
  • Set the Bearer Token input to the value of the bearer token you received from the Microsoft Graph Authentication VBO.
  • Set the File Path input to the location where you want the file written to.
  • Set the Method value to GET.
Cheers,

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

Hi Eric,

I am able to run the Download File action for an excel file without any issue as received HTTP response as 200. However, i can't see any files in downloads folder. Any idea where exactly the files are gettings downloaded in machine ?

------------------------------
Kamal Ahmed RPA Developer
Sr. Programming Analyst
BNY Mellon
Asia/Kolkata
------------------------------

Hi @Kamal2017,

Let's make sure we're on the same page. When you say you can run the Download File action, you're referring to the action on the actual Microsoft Graph - Sharepoint connector, correct? If so, you need to understand that the Web API Service feature of Blue Prism does not actually download files per-se. What it does is captures the response body of the request and presents it to you, as text, in the Response Content output item. It doesn't write anything to disk.

So, if the content of the response is really just a text-based file you should be able to take the value of Response Content and write it to disk yourself (ex. using the Utility - File Management VBO) and you're good to go. Where the Web API Services feature croaks is when the content of the response body happens to be binary data (ex. a PDF). In that situation, the Web API converts the content to a string. This conversion basically corrupts the content. From what I've seen there's usually a loss of a certain number of bits. So if you were to try writing the Response Content to disk, as mentioned above, and then tried opening the file you would get an error from the application (ex. trying to open the PDF in Adobe).

That's why I mentioned the use of the Utility - HTTP VBO above.​ The HTTP Request File action, of that VBO, properly handles both text and binary file types and it exposes a property that you can set to the path where you want the downloaded file written to.

Cheers,


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

Hi Eric,

Yes, I was referring Microsoft Graph - Sharepoint connector only. Thanks for sharing the information how the download File action works. This made things clear.

About the Utility - HTTP VBO,  Is the HTTP Request action and HTTP Request File action are different or one of the same thing ? If same, i am not able to find any File path attribute in this. I have atatched the same for your reference. Could you please assist.

------------------------------
Kamal Ahmed RPA Developer
Sr. Programming Analyst
BNY Mellon
Asia/Kolkata
------------------------------

@Kamal2017,

You may need to download the most recent version of the VBO from the Digital Exchange. You can find it at the link below:

https://digitalexchange.blueprism.com/dx/entry/3439/solution/utility---http

Cheers,


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

Hi Eric,

Appreciate all your help. I downloaded this utility and it worked for me to download the respective files from SharePoint online to local drive.

I need one more favor on the action 'Update List Item Column Value' for Microsoft Graph - Sharepoint connector web API. This ask for the json payload and it tried all permutation and combination to do so but it throws the error either as invalid request or incorrect json format (ref. image uploaded). Could you please help me out to get the json format it works with this action.

------------------------------
Kamal Ahmed RPA Developer
Sr. Programming Analyst
BNY Mellon
Asia/Kolkata
------------------------------

Hi Eric,

In continuation to my earlier email, looking for your help for Microsoft Graph - Sharepoint connector web API - action 'Update List Item Column Value'. I am able to run this successfully now with json format, however it looks that it doesn't update the new value. I tried it multiple times with success but can't see this on response recieved from that call.

Any help will be appreciated.


------------------------------
Kamal Ahmed RPA Developer
Sr. Programming Analyst
BNY Mellon
Asia/Kolkata
------------------------------

Hi @Kamal2017,

Sorry I wasn't able to respond yesterday. Can you share the JSON payload (remove or blackout any secure information), so I can see what you're submitting? How many columns are in this list?

Cheers,


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

@Kamal2017,

FYI - This seems to work for me on my test SharePoint site. One thing you might want to check is the properties of the field (aka Column) you're trying to update. They can be marked as read-only. They can also have an associated calculation that must be met for things to work properly. Not sure if these apply to your specific case, but you should verify.

In my case, I added a Single Text Line column, named Test Column, to an existing list of documents as pictured below:
31019.png After that, I used the Graph action to update the value of the column on the item Test1.xlsx to set the value to This is a test as shown below:
31020.png
And this is the JSON I used:
{
    "TestColumn": "This is a test"
}​
 
Please note, the name you use to reference the column in the JSON, is NOT the displayName (i.e. the displayed name of the column). It's the name (i.e. internal name). You can find the name of the column by enumerating the list's columns. We don't have an action in the connector for that, but you can add one easy enough. Just copy the Get List by List ID action and add /columns to the end of the URL Path:

/sites/[Site ID]/lists/[List ID]/columns

Cheers,

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