Has anyone used the Campaign Monitor to receive subscription updates via the Campaign Monitor webhooks? I have configured the webhook to post json data to a page on our website, however when my code receives the data it is just a bunch of zero's. My code is as follows:
System.IO.Stream stream = Request.InputStream;
byte[] byteData = new byte[Convert.ToInt32(stream.Length)];
int read = stream.Read(byteData, 0, Convert.ToInt32(stream.Length));
string streamData = string.Empty;
string somedata = System.Text.Encoding.ASCII.GetString(byteData).ToString();
for (int i = 0; i < Convert.ToInt32(stream.Length); i++)
{
streamData = streamData + byteData[i].ToString();
}
I've tried posting data to my page and it works - i.e. the code above (somedata) returns the same text value that I posted to the page. Very frustrating....
Any ideas anyone? I've lost lots of hair tonight!!!
Thanks in advance Al
You can read the body of the request as follows (from a webforms app):
The docs specify that the data you're expecting for the subscribe event is of the form:
You could test this out yourself by submitting POST requests to your URL using the example data above. Here's an example using curl: