Hello All,
Is there a way to easily convert from Base64 to an attachment? Iam downloading Base64 code from the API into an attribute. I would like to be able to visualize it as a PDF.
Hello All,
Is there a way to easily convert from Base64 to an attachment? Iam downloading Base64 code from the API into an attribute. I would like to be able to visualize it as a PDF.
Hello Paweł,
I'd need a bit more information here on what is the direction, and where you want to display the PDF.
Is it downloaded from Webcon API to external system?
Is it downloaded from external system via it's API to Webcon?
Webcon itself assumes that all the files sent to it via API will be Base64* encoded, so in this case it should just work.
You should also be able to use Add attachment action** with SQL configuration SELECT convert(image,<binaryContent>) AS Content, 'file1.txt' AS FileName.
In the <binaryContent> if i understand the docs well it should be a Base64 converted into VARBINARY(MAX) - you'll have to check how to handle it.
* https://developer.webcon.com/docs/attachment-operations/#start-an-instance-with-attachment
** https://docs.webcon.com/docs/2026R2/Studio/Action/Attachments/Action_AddAttachment#5-based-on-sql-query
Dear Paweł,
I think the easiest way is to use the Add Attachment action and use an SQL query there.
More details and step-by-step instructions can be found here:
https://docs.webcon.com/docs/2026R2/Studio/Action/Attachments/Action_AddAttachment
PS. Assume that you already have the PDF encoded as Base64. :)
Hello Paweł,
I'd need a bit more information here on what is the direction, and where you want to display the PDF.
Is it downloaded from Webcon API to external system?
Is it downloaded from external system via it's API to Webcon?
Webcon itself assumes that all the files sent to it via API will be Base64* encoded, so in this case it should just work.
You should also be able to use Add attachment action** with SQL configuration SELECT convert(image,<binaryContent>) AS Content, 'file1.txt' AS FileName.
In the <binaryContent> if i understand the docs well it should be a Base64 converted into VARBINARY(MAX) - you'll have to check how to handle it.
* https://developer.webcon.com/docs/attachment-operations/#start-an-instance-with-attachment
** https://docs.webcon.com/docs/2026R2/Studio/Action/Attachments/Action_AddAttachment#5-based-on-sql-query
Hello Maksymilian,
I retrieve the value via REST API from an external source. The attachment value is passed to the technical field and is in Base64 format. I'm looking for a best practice to always convert it to an attachment in the workflow.
Hello Maksymilian,
I retrieve the value via REST API from an external source. The attachment value is passed to the technical field and is in Base64 format. I'm looking for a best practice to always convert it to an attachment in the workflow.
For my case I needed to get attachment data from larger JSON file. Here's the code:
SELECT
FileName,
Description,
CAST(AttachmentBase64 AS xml).value('xs:base64Binary(.)', 'varbinary(max)') as Content
FROM OPENJSON(JSON_TECHNICAL_ATTRIBUTE)
WITH (
FileName nvarchar(255) '$.InvoiceRequest.InvoiceAttachment.FileName',
Description nvarchar(255) '$.InvoiceRequest.InvoiceAttachment.Description',
AttachmentBase64 nvarchar(max) '$.InvoiceRequest.InvoiceAttachment.Attachment')
Mandatory properties of the file are "Filename" and "Content".
In order to show attachment on the form you need to enable showing first attachement on page load in selected step settings.
For my case I needed to get attachment data from larger JSON file. Here's the code:
SELECT
FileName,
Description,
CAST(AttachmentBase64 AS xml).value('xs:base64Binary(.)', 'varbinary(max)') as Content
FROM OPENJSON(JSON_TECHNICAL_ATTRIBUTE)
WITH (
FileName nvarchar(255) '$.InvoiceRequest.InvoiceAttachment.FileName',
Description nvarchar(255) '$.InvoiceRequest.InvoiceAttachment.Description',
AttachmentBase64 nvarchar(max) '$.InvoiceRequest.InvoiceAttachment.Attachment')
Mandatory properties of the file are "Filename" and "Content".
In order to show attachment on the form you need to enable showing first attachement on page load in selected step settings.
Thank You Martin,
Probably I do smth wrong and its not working.
Please take a look for it.
Thank You Martin,
Probably I do smth wrong and its not working.
Please take a look for it.
Hi Paweł,
based on what Martin wrote
> For my case I needed to get attachment data from larger JSON file. Here's the code:
You don't have the JSON, just raw base64, so that OPENJSON is not necessary.
Something like this should to the job:
SELECT
'attribute/constant filenae' AS FileName,
'attribute/constant description - this can be emtpy' AS Description,
CAST('WFD_AttributeX_Value' AS xml).value('xs:base64Binary(.)', 'varbinary(max)') as Content
Also make sure, that whole Base64 will fit into the attribute (use multiple line of text).
Hi Paweł,
based on what Martin wrote
> For my case I needed to get attachment data from larger JSON file. Here's the code:
You don't have the JSON, just raw base64, so that OPENJSON is not necessary.
Something like this should to the job:
SELECT
'attribute/constant filenae' AS FileName,
'attribute/constant description - this can be emtpy' AS Description,
CAST('WFD_AttributeX_Value' AS xml).value('xs:base64Binary(.)', 'varbinary(max)') as Content
Also make sure, that whole Base64 will fit into the attribute (use multiple line of text).
Thank you,
My problem has been solved. With this configuration, the attachment is created as I wanted.