Error while sending pdf file in Post method of http rest api

Hi,
I am using http post method where I need to send pdf file along with the api.
Below is my configuration that I put in the http request activity.

I am getting response as below

image

I have already mentioned the full file path still its showing the above response.
Can anyone please suggest what can be the issue over here ?

Hi! @Debartha_Mitra_DE ,

Pass the file path through a variable with the extension “.pdf”.

Regards,
NaNi

Hi,
Thanks for your response, I did it in this way as well.
But no luck.

image

Hi!
please try this.

fileNamePath=Directory.getfiles("D:/-----.pdf").ToString

Regards,
NaNi

Hi,
you mean to say similar like this ?

Directory.getfiles(“C:/Users/DE118723/Documents/UiPath/UiPath DocDigitizer API/Rechnung201Redacted.pdf”).ToString

This code is throwing error (invalid directory name) as this code usually asks for directory name not the file name

Let me know if I am making any mistake or not.

hey! try like this

  1. Use assign activity :
    fileNamePath=directory.GetFiles(FolderPath)
    FolderPath= Path of folder where your files are present
  2. Use for each activity
    Inside body of for each use if condition activity
    item.Contains(“.pdf”)

Here you’ll get the files which contains the .pdf extension.

Regards,

Hi

Have a view on these threads for different approaches

Cheers @Debartha_Mitra_DE

I tried this but it threw the same error

I need to send pdf file through rest api request, i tried to use the below code to upload it mentioned in

and this is my code in the invoke code activity

Dim client As RestClient = New RestClient("https://xxcccc")
client.Timeout = -1
Dim request As RestRequest = New RestRequest(Method.POST)
request.AddHeader("Authorization", "token key")
request.AddHeader("Content-Type", "application/octet-stream")
request.AddHeader("Content-Disposition", "form-data")
request.AddParameter("filename", "Rechnung201Redacted.pdf")
request.AddFile("file", "C:\Users\DE118723\Documents\UiPath\UiPath DocDigitizer API\Rechnung201Redacted.pdf")
Dim response As IRestResponse = client.Execute(request)
Console.WriteLine(response.Content)

can you please tell what can be the issue over here, its not working

@gustavo.cervelin if you can also help me here it will be very helpful