I am trying to run the below C sharp code in UiPath using invoke code activity. I know the regular C sharp codes do not work in invoke code activity directly, can any one help me in compacting/ making the below code running state using invoke code activity.
public virtual ActionResult Download()
{
ClientContext ctx = new ClientContext("https://ABC.sharepoint.com");
SecureString passWord = new SecureString();
foreach (char c in "Pass@word12".ToCharArray()) passWord.AppendChar(c);
ctx.Credentials = new SharePointOnlineCredentials("abc@gmail12.com", passWord);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var fileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(ctx, "/sites/Test/testdoc.docx");
return File(fileInfo.Stream, "application/octet-stream", "testdoc.docx");
}
You would require to install the Below Package for Resolving Namespace Validation issues I suppose :
or Install the below Dependencies of the Package separately, if not present already by Checking in the Imports Section :
We do have the Sharepoint Activities that should do a Similar Operation as you are trying to perform using the c# Code, you could use it too instead of the Code.
As @supermanPunch mentioned install that dependencies and use the activity instead of code. It will be very easy to download the files using those activity