i've been following this Making a cURL call in C# for trying to make a request with the LiveChat API in curl and receive the result on my C# application,
the request should be filled as the following as explained in: http://developers.livechatinc.com/rest-api/#!introduction
curl "https://api.livechatinc.com/agents" \
-u john.doe@mycompany.com:c14b85863755158d7aa5cc4ba17f61cb \
-H X-API-Version:2
This is what i did in C#:
static void Main(string[] args)
{
RequestTest();
Console.ReadKey();
}
private static async void RequestTest()
{
var client = new HttpClient();
// Create the HttpContent for the form to be posted.
var requestContent = new FormUrlEncodedContent(new[] {new KeyValuePair<string, string>("myemail:myapikey", "X-API-Version:2"),});
// Get the response.
HttpResponseMessage response = await client.PostAsync(
"https://api.livechatinc.com/agents",
requestContent);
// Get the response content.
HttpContent responseContent = response.Content;
// Get the stream of the content.
using (var reader = new StreamReader(await responseContent.ReadAsStreamAsync()))
{
// Write the output.
Console.WriteLine(await reader.ReadToEndAsync());
}
}
The result seems to be allways the same "Cannot POST to /agents"