Issue with http request

Facing issue while opening a file which I downloaded as https response. Thanks in advance
P.S.> I am passing exactly the same document name which I retrieved from ticket json details.

Hi @anjasing

If you are using HTTP Request Activity, in Filename for response attachment field, type the name with file extension


it could be due to a few reasons:

  1. Incorrect Format: The file might not be in a bitmap format, or the format may not be supported by Paint. Ensure you’re downloading the file in a format that Paint recognizes, like BMP, JPEG, or PNG.
  2. Improper Saving: UiPath might be saving the HTTP response as text rather than as a binary file, which would corrupt an image file.
  3. Partial Download: The file may not have been completely downloaded, resulting in a corrupted file.

To resolve the issue, follow these steps in your workflow:

  1. Use the Proper Activity: Ensure you’re using the “HTTP Request” activity to download the file and that you’re accessing the response content correctly.
  2. Save as Binary: When saving the file, use the “Write Bytes” activity to write the response content to a file rather than “Write Text” to ensure the binary data is preserved.
  3. Check Response Content: Before saving the file, verify that the HTTP response status is successful (Status Code 200) and that you’re actually receiving binary data intended to be an image file.
  4. Error Handling: Add error handling to manage scenarios where the download might fail or the file might not be the expected image.

Here is an example of how you might set up the activities:

  • HTTP Request Activity:
    • Set the ‘EndPoint’ property to the URL from which you are downloading the image.
    • Set the ‘Method’ property to “GET”.
    • Save the ‘Result’ property to a variable (e.g., httpResponse).
  • Check Status Code:
    • Use an “If” activity to check if httpResponse.StatusCode is 200.
  • Write Bytes Activity (inside the ‘Then’ section):
    • For the ‘Path’ property, provide the file path where you want to save the image.
    • For the ‘Bytes’ property, use httpResponse.Content.
  • Error Handling:
    • Use a “Try Catch” block around the HTTP request to handle any exceptions that may occur.

hi @srinivasmarneni ,

I am unable to find write bytes activity in UiPath. Can you please guide here

Write byte directly not available…

  1. Create Byte Array Variable: In UiPath, create a variable named fileBytes of type Byte[] and assign it the byte data that you wish to write to the file.
  2. Specify File Path: Create a string variable named filePath where you will save the file. Assign it the full path, for example, "C:\path\to\your\file.txt".
  3. Drag “Invoke Code” Activity: Add the “Invoke Code” activity to your workflow where you need to write the byte array to the file.
  4. Input the Code: Click “Edit Code” in the “Invoke Code” activity and enter the following code:

System.IO.File.WriteAllBytes(filePath, fileBytes)

  1. Bind Arguments: In the “Arguments” property of the “Invoke Code” activity, add your filePath and fileBytes variables with the direction set to “In”.

Here’s how the “Arguments” binding would look:

  • Name: "filePath", Direction: In, Type: String, Value: filePath (your variable)
  • Name: "fileBytes", Direction: In, Type: Byte[], Value: fileBytes (your variable)

After setting up, when the “Invoke Code” activity runs, it will execute the code and write the contents of fileBytes to the file specified in filePath.

Remember to replace "C:\path\to\your\file.txt" with the actual path where you want to save the file, and ensure that fileBytes contains the byte array data you wish to write.

1 Like
  1. assign it the byte data that you wish to write to the file.

fileBytes = Convert.FromBase64String(?)
what needs to be put here in ? specially from https response

@srinivasmarneni Please guide here

When we want to catch a returned file with the HTTP Request activity (assumption:binary data is sent) we would use “Filename for response Attachment” as mentioned by

as an alternate you can also try

When the file is sent as base64 encoded data, we can check once we received the file:

  • read in the file e.g. Read text file (ensure using the right encoding, start with default UTF)
  • Convert from Base64 to binary or use the Base64 for the image conversion

We prooved in RnDs that in some scenario a call is not returning a response attachement file and the received response is not useable due damaged wrong encoding handling.

In such a case, we could setup a custom HTTP Call handling e.g using HttpClient.

When the url is public, just share it with us. If more help is needed, then share with us, what Http Request is returning

you can use the Convert.FromBase64String method.

Here’s how you do it:

  1. Obtain the Base64 encoded string from your HTTP response. Let’s assume you have this in a string variable named base64EncodedString.
  2. already created fileBytes.
  3. Use an Assign activity to convert the Base64 string to a byte array:

fileBytes = Convert.FromBase64String(base64EncodedString)

In the Assign activity:

  • For the To field, input fileBytes.
  • For the Value field, input Convert.FromBase64String(base64EncodedString).

Replace base64EncodedString with the actual string variable that contains your Base64 data. If this data is coming directly from an HTTP response, you would first extract it from the response content, which might look something like this:

// Assume ‘httpResponse’ is your HTTP response variable
base64EncodedString = httpResponse.Content.ReadAsStringAsync().Result

Once you have the Base64 string, you can then use Convert.FromBase64String to get the byte array as shown above.

here example:
// Extract Base64 string from HTTP response
base64EncodedString = httpResponse.Content.ReadAsStringAsync().Result

// Convert Base64 string to byte array
fileBytes = Convert.FromBase64String(base64EncodedString)

// Now you can use ‘fileBytes’ as needed, for example, to write to a file
System.IO.File.WriteAllBytes(filePath, fileBytes)

base64EncodedString = httpResponse.Content.ReadAsStringAsync().Result

giving issue content is not a member of string

What I did >>

  1. HTTP Request (Properties: Output → response content → used variable httpResponse)
  2. assign: baseEncodedString = httpResponse.Content.ReadAsStringAsync().Result
  3. Assign: fileBytes = Convert.FromBase64String(base64encodedstring)
  4. Assign: filePath = Path where I want to save file
  5. Invoke code >> like you mentioned

as mentioned can result to:

Okay, Let me try this approach

hope you have seen:

and also

e.g as text file

1 Like
  1. HTTP Request (
    Properties: Output → response content → used variable httpResponse
    Properties: Options → reponse file → used variable FileNameReponse )
  2. read text file (default encoding) ->>
    input variable: used FileNameReponse
    output variable ->> documentNameCOnverted

As an ongoing thread with 15 ping-pongs lets avoid additional ping-pongs and lets com straighforward to solution or issue detection

We assume this one:

So can you share the file?

Sorry, it’s a sensitive file. Won’t be possible to share here. Let’s me try it from my end and would here if issue persists. Thanks

But you can open within a text editor e.g. notepad++ and can share with us the first start content. (from this screenshot we never can decode any sensitive information).

By the way, had you ever tried within the immediate panel
new UiPath.Core.Image(YourStringFromReadTextFile)

Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

Hi @ppr ,

It’s not showing anything in base64 format in below mentioned part:
We assume this one:

It’s giving a JSON response which we usually get after http response.


Can you please help here @ppr

show us a screenshot from you modellings please. thanks