0

I'm trying to configure an email in Marketing Cloud with the ampscript function HttpGet in order to retrieve a coupon from an external system. I've seen that the HttpGet could return these values

  • 0 indicates status is OK
  • -1 indicates missing URL
  • -2 indicates HTTP request error
  • -3 indicates empty content - the function completed successfully but returned no content

How can i manage errors e.g. time-out of this external system? At the same time the system gives me a XML response, i would like to manage fallbacks if there are syntax code error; how can i validate XML response using Ampscript adding a fallback? Because i implemented the function BuildRowSetFromXML, but i didn't see anything used to handle this.

Do you have any suggestions?

1

If I understand your question correctly, you'd need to encapsulate your AMPScript in an SSJS Try/Catch block to handle errors from AMPScript...

<script runat=server>
try {
</script>

%%[
  SET @try = "Ampscript to try - may raise an error"
]%%

<script runat=server>
}
catch(err) {
</script>

%%[
  SET @catch = "Ampscript to execute - try raised error"
]%%

<script runat=server>
} 
finally {
</script>

%%[
  SET @finally = "Ampscript to run irrespective of outcome of try"
]%%

<script runat=server>
}
</script>

A word of caution would be to not consider doing any of this, including your HttpGet from a mass send. HttpGets are slow and mixing AMPScript and SSJS is slow. I would reserve this type of thing for triggered sends where the email taking a few seconds longer to deploy to the customer isn't an issue. One million subscribers' emails each taking a few seconds longer each to deploy is a problem.

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.