cancel
Showing results for 
Search instead for 
Did you mean: 

compiler error at line 0

SanjayKumar2
Level 3
Hi, We are trying to add code to create folder in sharepoint site. we have come up with a method which works perfectly fine in VS 2017. But when we add it to a code stage we are getting the below errors. Framework : 4.0 & Any CPU 1) Compile error at line 0: } expected. 2) Compiler error at top section line 102: type or name space definition or end of file expected. Please find below the code which is in code stage public string checkAndCreateFolder(string TargetPath,string FolderName, string UserName, string Password) { try { string returnstring=""; Uri targetUri = new Uri(TargetPath); var sitePath = string.Format("{0}{1}{2}/{3}{4}", targetUri.Scheme, Uri.SchemeDelimiter, targetUri.Host, targetUri.Segments[1], targetUri.Segments[2]); var context = new ClientContext(targetUri); context.ExecutingWebRequest += ctx_ExecutingWebRequest; context.RequestTimeout = 3600000; // If the settings specify an user and password for the SP connection use them. if (!string.IsNullOrEmpty(UserName) && !string.IsNullOrEmpty(Password)) { context.Credentials = new NetworkCredential(UserName, Password); } else { context.Credentials = CredentialCache.DefaultCredentials; } context.ExecuteQuery(); Folder test = context.Web.GetFolderByServerRelativeUrl("EngagementDocumentLibrary/"+FolderName); context.Load(test); try { context.ExecuteQuery(); if (test.Name != null) { returnstring = "folder already exists"; } } catch (Exception ex) { context.Web.Folders.Add("EngagementDocumentLibrary/" + FolderName); context.ExecuteQuery(); returnstring = "folder created Succesfully"; } return returnstring; } catch (Exception ex) { throw ex; } } private void ctx_ExecutingWebRequest(object sender, WebRequestEventArgs e) { if (e != null) { e.WebRequestExecutor.WebRequest.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f"); } }
4 REPLIES 4

OlaNykvist
Level 3
Code in code stages should not include the method signature - it's generated automatically. Remove the signature and the corresponding { and } and it should work. EDIT: And another thing, you don't return values in code stages - you assign out variables instead.

SanjayKumar2
Level 3
Thank you for the update it worked.

Hi , 

There is an API which i need to get an access token but API body is  form data  so i created C# code which i getting below errors. Please find the attached screenshot and could you please help me ?

23898.jpg



------------------------------
Revathi A
------------------------------

Hello Hi Revathi A,,

 

When debugging in the IDE does the problem occur or only in blueprism? Try refactoring and using the call with synchronization methods.

 Check, if it only occurs in BP, validate dependencies, and I would suggest carrying out debugging by blocks.

 

Regards.



------------------------------
Leonardo Soares
RPA Developer Tech Leader
Bridge Consulting
América/Brazil
------------------------------

Leonardo Soares RPA Developer América/Brazil