File : subscriber.xml containing the New Subscriber Details
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 :
Any Ideas ?
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:
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 :)