Sharepoint activity - 401-Unauthorized error when trying to upload file to Sharepoint

Hi,
I’m trying to use the “Upload file” activity in UiPathTeam.SharePoint.Activities package 1.3 version. The credentials I have given is correct and I’m able to upload a file manually to the sharepoint. But using the “Upload file” activity, unauthorized error is thrown. Could you please check whether the format of Item URL or Local path is fine? I tried multiple combinations of the Item URL, but getting same error.

Error: RemoteException wrapping System.Net.WebException: The remote server returned an error: (401) Unauthorized.

Item URL: “Documents\RPA\New\Sample.xlsx”
Local Path: “C:\Users\vijayakumar.chandran\Desktop\Sample.xlsx”

Hi @ Vijay_chandran,

see this post will help you

1 Like

Thanks for the reply @Luis261980. I have gone through this post. In the Item URL I have mentioned the sharepoint library name at the beginning but still facing the same error.
Note: I have used “Create Folder” activity in Sharepoint scope and that is working fine, so the credentials used to connect are correct.

@radu_bucur - FYI please.

Try full path on ITEM URL

Hi @Luis261980 - I have tried below paths in ITEM URL, getting same unauthorized 401 error for all. But using Create Folder activity, I’m able to create folder in the same sharepoint path.

ITEM URL tried:
“/Documents/RPA/Sample.xlsx”
“Documents/RPA/Sample.xlsx”
“Documents/RPA”
“C&H-Work Meeting Prep/Documents/RPA/Sample.xlsx”
“/C&H-Work Meeting Prep/Documents/RPA/Sample.xlsx”
https://mnscorp.sharepoint.com/sites/CH-WorkMeetingPrep/Documents/RPA
https://mnscorp.sharepoint.com/sites/CH-WorkMeetingPrep/Documents/RPA/Sample.xlsx
https://mnscorp.sharepoint.com/sites/CH-WorkMeetingPrep/Shared%20Documents/Forms/AllItems.aspx?viewid=79f59b52-9bee-4f51-8048-9c5e37ff86ed&id=%2Fsites%2FCH-WorkMeetingPrep%2FShared%20Documents%2FRPA

Wait i will call the cavalery :slight_smile:

@aksh1yadav

@ClaytonM

@lakshman

@loginerror

@ sudhasagar

@ Palaniyappan

any help here please, tnhx

1 Like

Try “/Shared Documents/RPA/” it might work.

If you say Create Folder is working fine and that you indeed have permissions to upload files, this should work too. If it doesn’t, please go through the questions below
Are you trying to overwrite a new file or to upload a new one?
If you want to overwrite, are u sure the file is not checked out or that someone is editing it?
Could you possibly share the code with us? (minus the credentials) This way we could see if there indeed is a problem.

1 Like

Thanks Radu. The file gets uploaded to the sharepoint by using “/Shared Documents/RPA/” Note: I was getting a different error (File not found) even after successful upload with above mentioned URL. Then I changed the Item URL to “/Shared Documents/RPA/Sample.xlsx”, after which I’m not getting error.
Thanks lot for your help.

2 Likes

No problem, its something that’s specified in the documentation of the package. SharePoint has certain exceptions like that (SharePoint be crazy). Glad it worked out!

1 Like

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