HTTP request how to pass file in parameter?

How to pass a file path to a API call in HTTP request.
I have the URL and key that works fine. The API will convert that file and return me a ID(in numbers) but if i pass file as a parameter in string throws empty error

@Stealth_Coder

I guess we can’t pass the file directly into the Http request. You need to convert it to Base64 format first and then you can pass that string to your request.

Can you tell me how to do that?

but one of the parameter for the API is file

|file|File|Yes*|Captcha image file.

    • required if you submit image as a file (method=post)|
      | — | — | — |

@Stealth_Coder

Try below steps.

  arrBytes  = File.ReadAllBytes("File path")
  FileData = Convert.ToBase64String(arrBytes)

Here arrBytes variable is of type Array of Bytes and FileData is of type String.

Pass FileData variable into your request.

Thanks,
But where to try these? Which command?

and after converting to base64 how to pass it to HTTP request?

Hi,

Could you please send your file as file path in the attachments section in Http request activity. not sure on this. please try.

Regards,
Kirankumar.

@lakshman ,

I’m getting ReadAllbytes is not a member of string

arrBytes is not a string type which suggested by @lakshman . he is the correct person to answer your question. thanks.

Regards,
Kirankumar.

@kirankumar.mahanthi1 ,

Its a captcha image which i want to send to the api to get a code…and again code i will send to another end point that will solve the captcha…the second part is working.But first of uploading file to get a code is not working even if i send as attachment

ok got your question. please try the solution suggested by @lakshman. thanks.

I created arrbytes as bytes only then also saying the same error