Add contact to StreamSend using C#

240 views
Skip to first unread message

GregFinzer

unread,
Jan 24, 2010, 8:44:15 AM1/24/10
to StreamSend API Discuss
How do I add a contact to StreamSend using C#?

Thanks,
Greg

Dave Merrill

unread,
Feb 15, 2010, 12:19:06 PM2/15/10
to StreamSend API Discuss
Here's some sample code.

Uri addy = new Uri("https://app.streamsend.com/audiences/2/
people.xml");
HttpWebRequest request = WebRequest.Create(addy) as
HttpWebRequest;
request.Headers.Add("Authorization: Basic " +
base64Encode("login:password"));
request.Method = "POST";
request.Accept = "application/xml";
request.ContentType = "application/xml";

StringBuilder data = new StringBuilder();
data.AppendLine("<person>");
data.AppendLine("<email-address>te...@example.com</email-
address>");
data.Append("<first-name>Test</first-name>");
data.AppendLine("<last-name>Person</last-name>");
data.AppendLine("</person>");

byte[] byteData =
UTF8Encoding.UTF8.GetBytes(data.ToString());

request.ContentLength = byteData.Length;
Stream sPost = request.GetRequestStream();
sPost.Write(byteData, 0, byteData.Length);

HttpWebResponse response = request.GetResponse() as
HttpWebResponse;
StreamReader srResponse = new
StreamReader(response.GetResponseStream());

Console.WriteLine(srResponse.ReadToEnd());

I hope that helps!

Dave

GregFinzer

unread,
Feb 16, 2010, 11:08:40 AM2/16/10
to StreamSend API Discuss
Hey thanks Dave! I am actually starting to create a StreamSend
Library now in C#. Good luck with your integration.

Prabhu Kameswaran

unread,
Apr 30, 2014, 10:28:17 AM4/30/14
to streamsend-...@googlegroups.com
I am getting 404 error for this xml i tried to send to the uri mentioned. Could you please reply. Thanks.

Jim Leggett

unread,
Apr 30, 2014, 2:53:55 PM4/30/14
to streamsend-...@googlegroups.com
Don’t know if this is your problem but if you have the wrong audiences value you can get a 404.
In the sample below you have the as audiences/2/...  
Maybe your account should be audiences/1/...  ???
--

---
You received this message because you are subscribed to the Google Groups "StreamSend API Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to streamsend-api-di...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages