Skip to main content

Hello,

 

We are trying to create email drafts using web connectors. 

We managed to easily create the e-mails drafts but the problem is that we cannot add attachments to them.

We are trying to pass a parameter that contains the file data as varbinary using both HTTP connector and the Web Connector

       1.For the HTTP connector we have defined the following inputs:

The {file_storage} is a varbinary variable that contains the file in base64.

We have a task at the beggining and one af the end for checking the file storage values and they both show up as base64:

base64
​​​​

The task input parameter shown above also has the type varbinary.

When we run with the variable, we recieve this error:

If we hardcode the {file_storage} with the result from the incoming_storage] value, the attachment is working fine and the file is not corrupted. Yet, if we use it as a variable defined in the process {file_storage}, then we receive the above error message followed by the code 400.

The conclusion we have is that the parameter is automatically converted to string when we enter it in the body of the HTTP request.

 

  1. For the Web Connector

For the Web connnector, we have designed a base URL one and an endpoint configured in the same manner as in the HTTP request

.We defined an input parameter named {file_storage} 

This request works, it attach the file to the email but the file is corrupted, getting this error message when opening the PDF.

We think that the encoding to Base64 is not working as intended.

 

Thanks!

Hello @TurcuPaulAndrei,

In your first example, regarding the HTTP connector, you wrote this:

The {file_storage} is a varbinary variable that contains the file in base64.

But I think there is a misunderstanding here. A varbinary variable cannot be “in base64”, because a varbinary variable simply contains binary data and base64 is a character encoding for binary data. In other words, base64 is text and if you want to insert base64 data into a JSON body, you should use a (n)varchar variable. The task input parameters do show the data as base64, but this is somewhat coincidental and not related to how the data is injected into the JSON body. The default behavior of Indicium when injecting a varbinary variable into a constant value is not to use base64 but rather UTF-8 encoding.

If you change the data type of the file_storage process variable to varchar(max) and then convert your binary data to base64 yourself and store it in that process variable, then it should work as expected. Note that my @binary_data in the example below is just made up to have some data to convert, but that it is referenced by name in the base64 conversion.

-- Assuming some binary data as input
declare @binary_data varbinary(max) = 0x54657374;

-- Convert the binary data to base 64 and store it in the file_storage process variable
set @file_storage = CAST('' AS XML).value('xs:base64Binary(sql:variable("@binary_data"))', 'varchar(max)');

This same solution should work for the web connector, but you will have to set pre-processing to Auto or None. We will be improving how the web connector works in the near future to make it so that your 2nd example would have worked.

I hope this helps.


Hi @TurcuPaulAndrei, did Vincent's reaction help you out or do you still require assistance?


Hi @TurcuPaulAndrei, did Vincent's reaction help you out or do you still require assistance?

@Jeroen van den Belt He is on vacation right now, but I've alerted him as well to react.