Sending HTML tag into custom field via API

I've successfully manually edited a custom field to contain a functional hyperlink via the CM interface. Now, I'm trying to send an anchor tag into the same custom field via the API, but I haven't been successful. I've tested my script in the browser, and it is printing as expected. Any idea what I'm doing wrong? Or is the API set up to strip HTML out? Should I be able to achieve success with this?

Thanks!

Mathew Mathew, 7 years ago

Can you please let us know what specific content you are trying to insert?


Get in touch with us on Twitter: http://twitter.com/campaignmonitor
We're also on Facebook: http://facebook.com/campaignmonitor
rsskga rsskga, 7 years ago

Sure, just

<a href="http://someurl.com">url text</a>

All the Queen's Men
An exceptional graphic design, web development and online marketing firm.
We communicate, execute, and exceed your expectations.
A San Francisco Web Design Company
Phil Phil, 7 years ago

Hi,

It's not so much that the API is stripping out the HTML, but that XML (the underlying data structure in this case) actually has several special characters which must be escaped. Look here for the list. If you escape the quotes and angled brackets you should be ok.

You'll probably also find that wrapping the entire link in CDATA tags will mean you can use it as is.

Phil Phil, 7 years ago

Hi again,

Apologies i should have attached examples to that last post:

If wrapping the HTML in CDATA, your link would look like:

<![CDATA[<a href="http://someurl.com">url text</a>]]>

If using escape characters, it would be:

&lt;a href=&quot;http://someurl.com&quot;&gt;url text&lt;/a&gt;
rsskga rsskga, 7 years ago

Brilliant! I tried the CDATA code first, and it worked like a charm. :)


All the Queen's Men
An exceptional graphic design, web development and online marketing firm.
We communicate, execute, and exceed your expectations.
A San Francisco Web Design Company

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098