1

We are creating HTML Emails and I want to get the content of them by SSJS but the problem is their type is not "Email" or "ContentBlock", it is like in the middle of those. I can retrieve their IDs, CustomerKeys or Names when I treat them as "Assets" but not the content.

Can you help me find a way to retrieve the content of an HTML Email?

4
  • 1
    To confirm, are you looking to retrieve the HTML content for an individual Subscriber, that is, view the rendered HTML which includes the personalized content (from AMPscript or SSJS code) for that Subscriber? Commented Aug 13, 2018 at 9:29
  • No, I am trying to get HTML body of an HTML Email including Ampscript. Commented Aug 13, 2018 at 9:32
  • 1
    Are these in Content Builder or Classic? Commented Aug 13, 2018 at 12:49
  • Content Builder. "Email" type can be used for Classic view. Commented Aug 13, 2018 at 13:56

1 Answer 1

1

This is not something that can be achieved in the native SSJS, AMPScript functions nor by the SOAP API. You will need to utilize the REST API to get this. This is because Content Builder assets are stored elsewhere than classic, which is where the native functions and SOAP are aimed at.

I would utilize the 'GET Asset' REST Call.

Sample of call (using SSJS - assuming you gathered the auth Token already):

var authToken = "Bearer: " + accessToken;

var url = 'http://{{yourendpoint}}/asset/v1/content/assets?$filter=Name%20like%20'{{yourEmailName}}'';
var headerNames = ["Authorization"];
var headerValues = [authToken];
var response = HTTP.Get(url, headerNames, headerValues);

In the JSON you receive via the response, you will find the email content in items > views > html > content

e.g.

{
    "items": [
        {
            "views": {
                "html": {
                    "content": "{{yourHTMLContent}}"
                }
            }
        }
    ]
}
6
  • Thanks a lot for your brief answer Gortonington. Could you please suggest an endpoint for S7 instance? I have tried "webservice.s7.exacttarget.com" but it didn't work. Commented Aug 14, 2018 at 11:23
  • @SelimSevim, that is the SOAP endpoint. Try using: https://www.exacttargetapis.com Commented Aug 14, 2018 at 15:47
  • I get this error: "Access Denied. URL: [www.exacttargetapis.com/asset/v1/content/assets?$filter=Name%20like%20'CO_DR_FLASH_DEAL_Q3_201808_KO_NA'] - from OMMCommon\r\n\r\n\r\n\r\n"}" Commented Aug 19, 2018 at 21:16
  • I would make sure your permissions are set appropriately, and then I would verify your authentication token Commented Aug 19, 2018 at 23:56
  • how can I check my permissions? Commented Aug 20, 2018 at 0:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .