Click here to Skip to main content
15,890,741 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Through this Apicall I have to insert all files from a Loklen folder into a folder in a specific software. the target folder is created by json. the loop iterates through the files and goes with each process in Apicall, which is designed for this according to the software documentation, but does not move the files to the target folder. when I use request.AddFile and use the parameters, a certain file is moved but not all files. I had to cover some places with a star because of data protection. how should I proceed so that all files in the local folder are moved? Thanks for answers


What I have tried:

C#
var files = Directory.EnumerateFiles(@"C:\Users\*******\Documents\*******", "*.*", SearchOption.AllDirectories)
          .Where(s => s.EndsWith(".jpg") || s.EndsWith(".pdf"));
            foreach (string i in files)

            {
                 IRestResponse response3;

                client = new RestClient("http://***.***.***.*");
                client.Authenticator = new HttpBasicAuthenticator("*******", "******");
                client.Timeout = -1;
                request = new RestRequest("/******/api/documents/******/" + folderid, Method.POST);
                request.AddHeader("content-type", "multipart/form-data");
                request.AlwaysMultipartFormData = true;

                request.AddParameter("Object", "{\r\n    \"cabinet\": \"Posteingang\",\r\n    \"name\": \"Dokument\",\r\n    \"objectTypeId\": \******\",\r\n   \"fields\": {\r\n        \"Datum\": {\r\n            \"internalName\": \"*******\",\r\n            \"value\": \"03.03.2021\"\r\n        },\r\n        \"Typ\": {\r\n            \"internalName\": \"feld4\",\r\n            \"value\": \"Brief\"\r\n        }\r\n    }\r\n}");
                //request.AddFile("file", );
                 
                request.AddFile("file" );

               

                response3 = client.Execute(request);
                Console.WriteLine(response3.Content);
Posted
Comments
[no name] 11-Mar-21 14:14pm    
Upload, then delete; what's so fascinating about "move"?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900