Skip to main content

Base64 Conversion for Files Using Automation Anywhere (A360)

  • January 22, 2026
  • 0 replies
  • 38 views
Forum|alt.badge.img+22

In many automation projects, bots need to exchange files with external systems like APIs, databases, or web applications. However, not all systems can directly send or receive physical files such as PDFs, images, or Excel sheets. Most of them work only with text data.

This is where Base64 file conversion becomes useful.

Base64 conversion allows us to convert a file into a text format so it can be safely transferred through APIs, JSON payloads, or stored in systems that do not support binary files. Later, the same text can be converted back into the original file without losing any data.

Approach Used in Automation Anywhere

Automation Anywhere does not provide a direct built-in action to encode or decode files into Base64. To handle this, we use a C# DLL that exposes functions for:

  • Encoding a file into Base64
  • Decoding a Base64 string back into a file

Download the DLL File

  • Navigate to the link provided to download the DLL file
  • During the download, if you see a security warning:
    • Click on the three dots
    • Select Keep to proceed with the download

Bot Build

Load the DLL

  • Use DLL: Open to load the C# DLL so the bot can access its functions during automation
  • Create a variable [sDllFilePath], or directly provide the DLL file path in the ‘File Path’ field
  • Set the session type as Local or Global Session, as required

Encode a File (Convert File to Base64)

  • Use DLL: Run Function to execute a specific function from the DLL
  • Update the parameters as follows:
    • DLL Session
      • Session name: EncodeOrDecode
    • Class Name
      • EncodeOrDecode
    • Function Name
      • EncodeFile
    • Input Parameters (1)
      • Parameter Name: filepath
      • Parameter Type: String
      • Value: Provide the file path you want to encode
        • Example: C:\test.pdf
        • You can also pass this using a variable

Decode a File (Convert Base64 to File)

  • Use DLL: Run Function to execute the decoding function
  • Update the parameters as follows:
    • DLL Session
      • Session name: EncodeOrDecode
    • Class Name
      • EncodeOrDecode
    • Function Name
      • DecodeFile
    • Input Parameters (2)
      • outputFilepath
        • Parameter Type: String
        • Value: Provide the output file path with file name and extension
        • Example: C:\Test.pdf
           
      • encoded
        • Parameter Type: String
        • Value: $sEncoded$
        • This value comes from the Encode File step
        • Alternatively, this can be a Base64 value received from an API response (for example, a nested JSON value that needs to be converted into a file on your local system)

 

Final Bot Flow

The completed bot should look like the configured steps shown below.

 

Debugging and Validation

  1. Place breakpoints at line numbers 4 and 6.
  2. Click the Debug button.
  3. Open Watched Variables.
  4. Under Add/Remove Watched Variables, select the ‘sEncode’ variable.
  5. Click Start Debugging.
  6. Verify the generated Base64 value:
    • The encoded output will look like random or gibberish text.
  7. Proceed to decode the Base64 value and save the file to your local drive.

Conclusion

This approach allows Automation Anywhere bots to work with file content that is exchanged as text. By using a DLL, the bot can convert a file to Base64 and convert it back when required, without changing the original file content.