Add a Subscriber to a list Format/Encoding required

POST http://api.createsend.com/api/v3/subscribers/{listid}.{xml|json}


File : subscriber.xml containing the New Subscriber Details

<Subscriber>
<EmailAddress>david1@icadretail.com</EmailAddress>
<Name>David1 Baggio</Name>
<Customfields>
<Customfield></Customfield>
</Customfields>
<Resubscribe>True</Resubscribe>
</Subscriber>

When I do a Post I Encode my API key as part of the HTTP Header

I use the actual Listid ( Not encoded) as the filename.xml

Do I need to Encode the XML data I am sending with the Request ?


The Delphi Mehod I am using to Post is:


1) Write the Subscribers Details to a XML File

2) Load the file into a MemoryStream

3) POST http://icadretail.createsend.com/api/v3/subscribers/123456789.xml
    sending the data as a Memorystream

4) The Response is Loaded into another Memorystream

The above Method works fine for retrieving information on Active Subscribers in the
same list :

GET  http://icadretail.createsend.com/api/v3/lists/123456789/active.xml?date=2012-06-01

Any Ideas ?

Phil Phil, 4 years ago

Hi icadretail,

You would know better than us the ins and outs of Delphi, but if that works well enough for GET methods then i would say you're on the right track.

With the post just make sure of these things:
1. Your Delphi code uses the appropriate http verb of POST
2. the xml is encoded properly for xml (there are some illegals characters, like &, which need to use proper xml-encoding)
3. An empty CustomField might result in an error. If you have no custom fields, just submit an empty collection, ie:

<Customfields></Customfields>

In terms of your pseudo-code, writing the xml to a file and then reading from that file does seem like unnecessary overhead; I would suggest looking into the possibility of writing your xml directly to the response body instead.

Hope that helps :)

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