I need to send a link to a CloudPage through SMS with an query param (www.example.com?id=XXXX), which the CloudPage will use to get value from a Data Extension and pre-fill some data to Contacts and ask for others.
This param value is different for each contact and the actual URL is too big, so I want to use Bitly to short this link. I can use AMPScript to create a dynamic link with Bitly, but this example is using V3 API, since it's going to be deactivated, I'm making it in V4.
The problem now it's I need to make an request through Bit.ly API with an JSON in request body, inside SMS message.
%%[
var @testID, @cloudpage, @link, @leadId, @bitlyPage, @contentType, @content,
@bitlyToken, @additionalHeaderName, @additionalHeaderValue, @output, @respheader
set @testID = 'XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
set @bitlyToken = 'myToken'
set @bitlyPage = 'https://api-ssl.bitly.com/v4/bitlinks'
set @contentType = 'application/json'
set @additionalHeaderName = 'Authorization'
set @additionalHeaderValue = concat('Bearer ', @bitlyToken)
set @cloudpage = CloudPagesURL(1591,'id',@testID)
set @link = URLEncode(@cloudpage)
set @content = Stringfy({"long_url": @link})
]%%
%%=HTTPPost2(@bitlyPage, @contentType, @content, true, @output,
@respheader, @additionalHeaderName, @additionalHeaderValue)=%%
Output: %%=v(@output)=%%
Header: %%=v(@respheader)=%%
When I try to run this in Preview and test, I get the following error:
There is an error in your email. Please contact your customer service representative. Error 1: Script SET Statement Invalid
An error occurred when attempting to resolve a script expression. See inner exception for detail. Script Expression: Stringfy MemberID: nnnnnnn JobID: 0 An unrecognized expression appears in a script block.
If I try without Stringfy, I get this error:
Error 1: Script SET Statement Invalid
An error occurred when attempting to resolve a script expression. See inner exception for detail.
How can I send this JSON data in body? or there is another way to make this Bitly link?