Hello everyone and thanks for the help in advance. I am writing an application that needs to POST Name-Value pairs along with some header details to an external api. Here is my code to this point:
HttpClient client = new HttpClient();
NameValueCollection nameValueCollection = new NameValueCollection();
nameValueCollection.Add("media_url", "https://mysite.com/test_fax.pdf");
nameValueCollection.Add("connection_id", "12345678");
nameValueCollection.Add("to", "+19999999999");
nameValueCollection.Add("from", "+19999999999");
var webRequest = new HttpRequestMessage(HttpMethod.Post, "https://api.telnyx.com/v2/faxes")
{
Content = new StringContent(nameValueCollection.ToString(), Encoding.UTF8, "application/x-www-form-urlencoded")
};
webRequest.Headers.Add("Authorization", "Bearer KEY12345");
var response = client.Send(webRequest);
var reader = new StreamReader(response.Content.ReadAsStream());
var responseBody = reader.ReadToEnd();
I am receiving an error message stating the api requires a parameter connection_id. Looks like I'm not transmitting data, but not sure why. Any help would be appreciated.