5

Im trying to get the SendPreview rendering of an E-Mail with Contact Data from an 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 an example: https://www.exacttargetapis.com/guide/v1/emails/103985/dataExtension/id:a2694402-4932-e611-a584-00110a6822ad/contacts/0/preview?kind=html

But it doesnt work. I allways 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?

Thanks a lot for your help

Ronald...

7

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>"
      }
    ]
  }
  • 1
    Does this work with content builder as well as classic builder emails? – Gortonington Feb 9 '17 at 12:23
  • Great question. I've tried but I get the error Email::BuildMessage(string, int)- This method can only be called with a valid Email ID. I can't see an easy way to get EmailID. I used my browser inspector to view the response payload when opening content builder and I'm using the ID value which I assume is correct. buy that's not working for me. – Eliot Harper Feb 10 '17 at 9:31
  • 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. – Gortonington Feb 13 '17 at 13:39
  • This did not work for me with Classic Content... – Dean Kuga Nov 8 '17 at 16:40
  • 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". – Luke Freeland Feb 18 at 16:32

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.