C# Example
Continuing from the example in Your First Message Template, you can send your transactional message in C# with the following.
1
var url = "https://txnhog.co/txn/api/your_message_key";
2
​
3
var httpRequest = (HttpWebRequest)WebRequest.Create(url);
4
httpRequest.Method = "POST";
5
​
6
httpRequest.ContentType = "application/x-www-form-urlencoded";
7
​
8
var data = "apiKey=sdkrjwhaldkgh3pwdfohawp4lyu&name=Shawn%20Spencer&phone=2085559988";
9
​
10
using (var streamWriter = new StreamWriter(httpRequest.GetRequestStream()))
11
{
12
streamWriter.Write(data);
13
}
14
​
15
var httpResponse = (HttpWebResponse)httpRequest.GetResponse();
16
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
17
{
18
var result = streamReader.ReadToEnd();
19
}
20
​
21
Console.WriteLine(httpResponse.StatusCode);
Copied!
Last modified 7mo ago
Copy link