hope that someone can help me here:

I'm trying to retrieve a simple result from a POST api call into ampscript variables. The cloudpage does show the variables as GTL, but when I try to display them as AMP script variables I get this as an output:

{{balance}} {{resetlink}} {{expirydate}}

This is the code I use:

%%=HTTPPost2('https://myurl','text/html', '', true, @Json)=%%  
%%{={{ }}=}%%
{{.datasource JSONVar source=@json type=variable}}
        { "target" : "@json" }

Balance = {{ balance }} <br>
Resetlink = {{ resetlink }} <br>
Expirydate = {{ expirydate }} <br>
SET @Saldo = TreatAsContent('{{balance}}')
SET @Reset = TreatAsContent('{{resetlink}}')
SET @Expiry = TreatAsContent('{{expirydate}}')


%%=v(@Saldo)=%% <br>
%%=v(@Reset)=%% <br>

What am I doing wrong here?

  • Unfortunately it results in the same when I use double quotes :/ – Louis Feb 26 '19 at 18:50
  • Removing my previous comment as it is incorrect, it is supposed to use the quotes on it. – Gortonington Feb 26 '19 at 18:59
  • I would try moving the {{/datasource}} below the var outputs. – Gortonington Feb 26 '19 at 19:00
  • 1
    I just learned from this example: gist.github.com/eliotharper/046cea2a299fd0b2168637db74a5d9fe That what I am trying to achieve does not work in cloudpages. I guess I'll have to switch to SSJS – Louis Feb 26 '19 at 20:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.