7

I'm trying to get the SendPreview rendering of an E-Mail with Contact Data from a Dataextension. The E-Mail includes AMPScript.

I tryed the following route:

https://www.exacttargetapis.com/guide/v1/emails/{emailID}/dataExtension/id:{dataExtensionGuid}/contacts/{rowNo.}/preview?kind=html

Here is an example:

https://www.exacttargetapis.com/guide/v1/emails/103985/dataExtension/id:a2694402-4932-e611-a584-00110a6822ad/contacts/0/preview?kind=html

But it doesn't work. I always get

    {
        "message": "Internal Server Error",
        "errorcode": 0,
        "documentation": "https://code.docs.exacttarget.com/rest/errors/500"
    } 

I found this solution in this thread but it seems not documented anywhere. How does the ExactTarget Email preview REST API work?

Is it possible to get a SendPreview rendering over API? And if yes how?

2 Answers 2

4

The following request works for me:

Host: https://www.exacttargetapis.com
POST /guide/v1/emails/[emailID here]/dataExtension/key:[DE External Key goes here]/contacts/key:[Subscriber Key that you want to preview here]/preview?kind=html
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN

This returns the response payload:

{
  "message": {
    "links": {
      "self": {
        "href": "/v1/emails/4144/dataExtension/0fa2a58b-39c5-e511-9164-00110a68d751/row/148/preview"
      }
    },
    "views": [
      {
        "contentType": "vnd.exacttarget.message.email.htmlBody",
        "content": "<html><head>\r\n</head><body>\r\n<h2>Hello Katie</h2>\r\n</body></html>"
      }
    ]
  }
15
  • 1
    Does this work with content builder as well as classic builder emails? Commented Feb 9, 2017 at 12:23
  • 1
    The only way I have found to 'easily' pull EmailID from content builder is with the EmailID string (%%_emailid%%) placed inside the email and then do a preivew. I have the feeling it may not work as the classic and content builder emails are stored in 2 completely different areas. I definitely HOPE this works though as I have been looking for this very thing for a while now. Commented Feb 13, 2017 at 13:39
  • 1
    There were multiple issues with mine but @EliotHarper was able to help me out and fix them. Make sure that the email content is Approved and available. Make sure that you do a "POST" and not a "GET" to the preview endpoint. Doing a "GET" was returning a 404 "Not Found". Commented Feb 18, 2019 at 16:32
  • 1
    @marioruiz this route still works. For Content Builder emails, remember to get the email id using the method in an earlier comment. Commented Aug 7, 2019 at 21:33
  • 1
    @EliotHarper thanks for figuring this out. I can confirm it works, although it's odd because I can pull the email id via the REST API, but the id I get from that call doesn't work, whereas the id I get from using %%_emailid%% does work. Commented Jan 27, 2020 at 20:18
14

This is an internal only route, that currently is NOT supported. It should not be used in production environments. The route has no ownership internally, and could stop working without notice.

You must log in to answer this question.

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