Upload multiple files in HTTP request using invoke code activity

Dim client As RestSharp.RestClient = New RestSharp.RestClient(Req_URL)
client.Timeout = 10000
Dim request As RestRequest= New RestRequest(RestSharp.Method.POST)
request.AddHeader(“AuthToken”, Token)
request.AddParameter(“binder_ld”, binder_id)
request.AddParameter(“isK1Document”, isK1Document)
request.AddParameter(“isBookmarkOnly”, isBookmarkOnly)
request.AddParameter(“isOCR”, isOCR) 9 request.AddParameter(“documentType”, documentType)
request.AddParameter(“submissionSource”, submissionSource)
request.AddFile(“file”, file)
Dim response As IRestResponse = client.Execute(request)
ResContent = response.Content.ToString

This is my code for upload documents in API.
It is working fine but only for one document. When I try to upload multiple document using comma separated path it is not working properly.

request.AddFile(“file”, file)

So file is argument which contains file path from Excel.

Hi @Harsh_Shinde

Try to make add file intput as list of filepath. Pass the list in invoke code activity. Use below sample code inside your code

Sample Code:

Dim filePaths As List(Of String) = New List(Of String) From { “filepath1”, “filepath2”, “filepath3” }

For Each filePath As String In filePaths
request.AddFile(“file”, filePath)


Invoke code: Exception has been thrown by the target of an invocation.

Still getting same error.



It might be because you are giving same name “file”

Instead you try with different names

And why not use http request activity instead?