[SalesForce] Get Preview of Email with AMPscript Using Rest API

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?

Best Answer

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>"
      }
    ]
  }
Related Topic