0

I am trying to get a json object from my email template using SSJS. Here is my code:

 <script runat=server>
    Platform.Load("Core","1.1.1");

   var responseContent = HTTP.Get('https://api.myjson.com/bins/o9qvd');

   var resp = Platform.Function.parseJSON(responseContent);
   var name = resp.name;

here is the url I am calling: https://api.myjson.com/bins/o9qvd

and here is the error I am receiving:

Unable to retrieve security descriptor for this frame. Line: 5 Char: 3 var resp = Platform.Function.parseJSON(responseContent)

then I plan to get the name value using Ampscript inside my html as below:

%%=v(@name)=%%

1

This worked for me. Have to use [0] for the response.

var content = Platform.Function.ParseJSON(result.Response[0]);
1

It's Platform.Function.ParseJSON(), with a capital "P" in Parse.

Also, you only need to parse the Content property of the response object.

<script runat=server>
Platform.Load("Core","1.1.1");
var response = HTTP.Get('https://api.myjson.com/bins/o9qvd');
Write(response.Content);
var content = Platform.Function.ParseJSON(response.Content);
Write("<br>Name:" + content.name);
</script>

Using a cloudpage and Write() to see the output is often the best way to debug this type of issue.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.