How to authenticate the Pardot API using HttpClient
<p>I struggled for about a day trying to authenticate against the Pardot API.  It didn't like how I was trying to post the message body.  So I wanted to post the solution that worked for me.  If you have any tips or alternatives I'd like to hear them.</p>

<pre><code>ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

var url = "https://pi.pardot.com/api/login/version/3";

//(Edit) Shorter way to pass the parameters below
//var postData = new List&lt;KeyValuePair&lt;string, string&gt;&gt;
//{
//    new KeyValuePair&lt;string, string&gt;("email", "&lt;value&gt;"),
//    new KeyValuePair&lt;string, string&gt;("password", "&lt;value&gt;"),
//    new KeyValuePair&lt;string, string&gt;("user_key", "&lt;value&gt;")
//};

var postData = new Dictionary&lt;string, string&gt;
{
    {"email", "&lt;value&gt;"},
    {"password", "&lt;value&gt;"},
    {"user_key", "&lt;value&gt;"}
};

var httpContent = new FormUrlEncodedContent(postData);

using (var client = new HttpClient())
{
    HttpResponseMessage response = client.PostAsync(url, httpContent).Result;

    if (response.IsSuccessStatusCode)
    {
        string resultValue = response.Content.ReadAsStringAsync().Result;
    }
}
</code></pre>

<p>Thanks!</p>