How to convert URL to Base64 guru ampscript?

375    Asked by ranjan_6399 in SQL Server , Asked on Feb 7, 2023

An external system generates the qr codes. On marketing cloud we have to retrieve the qr code, then url, after that i should encode it in base64 and show it as an image in a template.


this is the code i am using:

%%[
var @getRequest
set @getRequest = TreatAsContent(HTTPGet("https://api.qrserver.com/v1/create-qr-code/?size=300×300&data=https://sfmarketing.cloud/"))
set @enc = Base64Encode(@getRequest)
]%%
%%=v(@enc)=%%

from what I understand, it does not directly convert url to the correct base64 for me because if I try to do it in https://base64.guru/converter/encode/url

Answered by Anurag Singhal

To convert URL to Base64 guru ampscript:


%%[
VAR @img
SET @img = 'https://api.qrserver.com/v1/create-qr-code/?size=300×300&data=https://sfmarketing.cloud/'
SET @EncodedImg = Base64Encode(@img)
]%%
QR Image =
QR URL = %%=v(@img)=%%
QR Base64Encoder = %%=v(@EncodedImg)=%%

Your Answer

Interviews

Parent Categories