1

Is it possible to make a POST call using REST API in marketing cloud email template? Basically, what im trying to achieve is that when email is sent from marketing cloud, POST call should be made to the 3rd party tool and this POST call will send a html version of the sent email as a JSON file. Any suggestions are much appreciated.

2

If you need it real time, every time the email is sent, then it will need to be inside the HTML of the email and will likely greatly slow down your email sends. Depending on the volume as well as the file size, this potentially could cause errors in your send as well.

For the in email send you would:

  1. Create a var to hold the View As WebPage (VAWP) link SET @VAWPlink = AttributeValue("view_email_url")
  2. Create an AMPScript POST inside the email via HTTPPost2() passing the VAWP to your 3rd party system.
  3. Wrap this post in a conditional IF AttributeValue("_messagecontext") == 'SEND' AND AttributeValue("_isTestSend") == false THEN /* YOUR POST HERE */ ENDIF This will stop you from going into an infinite loop of POSTING when you grab the VAWP link.
  4. Have your 3rd party system do a GET to the VAWP link to get all the HTML.
  5. If you cannot have your 3rd party system do the GET, you will need to do the GET inside the email (not recommended) prior to the post to gather the HTML and then pass this to the system instead of the VAWP var. This way can cause an email to take a VERY long time to send.

The better option if you can have a delay would be to:

  1. collect the VAWP link
  2. Have the job id, email name and subscriberkey set as primary keys then upsert all of this info to a DE.
  3. Then have a script activity to GET the HTML and then POST it to your 3rd party system via a scheduled automation.

This will allow your sends to move much faster. There will still be a slowdown due to the UPSERT, but it will be much less than including the POST.

| improve this answer | |
  • thanks @gortonington. If 3rd party does GET will they need a access token and endpoint urls from marketing cloud? – Abhishek Jun 6 '18 at 5:10
  • I do not believe so as you would be hitting the public facing VAWP to scrape the HTML. – Gortonington Jun 6 '18 at 11:50

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.