I'd like to send an email to many Subscribers and retrieve content from an external URL (which is the same for each Subscriber), which will be used to personalise my email. Naturally, it's best practice to avoid making unnecessary requests (like the example below) as it may result in rate limiting and, well, it's just plain unnecessary.
%%[ /* How not to do it! */
var @url
set @url = HTTPGet('https://raw.githubusercontent.com/eliotharper/gtl-demo/master/featuredCases.json')
]%%
The solution? Content Syndication in the API. This is my new best friend. With Content Syndication, OMM will check if the content is cached, and if not then it will retrieve the external content, but if it's already been requested, then it will use the cached copy. Like this:
%%before;httpget 'https://raw.githubusercontent.com/eliotharper/gtl-demo/master/featuredCases.json'%%
This works well. However, I'd really like to get this to work in an AMPscript block, but I can't get this to work. I've tried this:
%%[
var @url
set @url = before;HTTPGet('https://raw.githubusercontent.com/eliotharper/gtl-demo/master/featuredCases.json')
]%%
and this:
%%[
var @url
set @url = before;httpget 'https://raw.githubusercontent.com/eliotharper/gtl-demo/master/featuredCases.json'
]%%
but in both instances, I get the error:
An unrecognized expression appears in a script block.
Does anyone know if there is a solution to this?
set @url = TreatAsContentArea(HTTPGet('https://myurl.com'))
I get the error "Object reference not set to an instance of an object."