SharePoint Activity - Get File

Hello,

I’m trying to download a file from an internal SharePoint folder while using UiPathTeam.SharePoint.Activities v1.3.0. I have used a SP Scope to authenticate, however, the Client Context is empty. I’m using my own credentials. I can upload a file, however, there is an error from UiPath saying error 404.

I get the below error when using the ‘Get File’ activity. I do not see any files downloaded after I get this error.

Error:

RemoteException wrapping System.Net.WebException: The remote server returned an error: (404) Not Found.
at System.Net.HttpWebRequest.GetResponse()
at Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()
at Microsoft.SharePoint.Client.ClientContext.GetFormDigestInfoPrivate()
at Microsoft.SharePoint.Client.ClientContext.EnsureFormDigest()
at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
at UiPathTeam.SharePoint.Utils.GetFileByUrl(ClientContext clientContext, String relativeUrl)
at UiPathTeam.SharePoint.Utils.GetFileFromSharePoint(ClientContext clientContext, String localPath, String relativeUrl)
at UiPathTeam.SharePoint.Activities.Libraries.GetFile.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

I tried using an ‘Upload File’ activity and it successfully uploaded a file. However, I get the below error. It says the server is not found, but once I refresh the SP site, the file has been uploaded.

Error:

RemoteException wrapping System.Net.WebException: The remote server returned an error: (404) Not Found.
at System.Net.HttpWebRequest.GetResponse()
at Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()
at Microsoft.SharePoint.Client.ClientContext.GetFormDigestInfoPrivate()
at Microsoft.SharePoint.Client.ClientContext.EnsureFormDigest()
at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
at UiPathTeam.SharePoint.Utils.UploadFile(ClientContext clientContext, String url, String localPath, Dictionary`2 itemProperties, Boolean allowOverwrite, Boolean queryInBatch)
at UiPathTeam.SharePoint.Activities.Libraries.UploadFile.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

I don’t know why this is happening. I’ve followed the instruction manual and can not authenticate and populate the ClientContext, nor download a file.

Any help is appreciated.
Thanks,
Brad

404 ?

Is your URL opening manually?

Make sure you are not connected to any VPN

@HareeshMR

Yes, the URL is opening manually.

I’m not on a VPN, but I’m on my companies network. I’m not sure if that could be the problem.

Even it is working in the company network, then it will not be the problem.

Your sharepoint domain URL will be different and the file URL will be different. Make sure you are giving the correct values :slight_smile:

@HareeshMR

These are the variables I’m using.

Scope
https://sharepoint.xxx.com/corp

Upload File

Item URL “/corp/Finance/Name/Shared%20Documents/Name/UIP%20Doc.pdf”

Local Path “C:\Users\Desktop\SharePoint_Custom_Activities_Documentation.pdf”

Can you try giving entire URL in the Item URL…

@HareeshMR

Error when I place the entire URL in the Item URL. The file does NOT upload to the SP folder.

RemoteException wrapping System.Net.WebException: The remote server returned an error: (400) Bad Request.
at System.Net.HttpWebRequest.GetResponse()
at Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()
at Microsoft.SharePoint.Client.File.SaveBinary(ClientContext context, String serverRelativeUrl, Stream stream, String etag, Boolean overwriteIfExists, SaveBinaryCheckMode checkMode)
at UiPathTeam.SharePoint.Utils.UploadFile(ClientContext clientContext, String url, String localPath, Dictionary`2 itemProperties, Boolean allowOverwrite, Boolean queryInBatch)
at UiPathTeam.SharePoint.Activities.Libraries.UploadFile.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

I completed the documentation again and followed the example. I have fixed my mistake. hopefully this helps others! I needed to continue the URL up until the ‘Shared Documents’ Folder.

Exception Scenario

Scope: https://sharepoint.xxx.com/corp/
Item URL: /corp/Ariba/Shared Documents/Ariba User List/test.xlsx

Solution:

Scope: https://sharepoint.xxx.com/corp/Ariba
Item URL: /Shared Documents/Ariba User List/test.xlsx

8 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.