I am able to successfully connect to an endpoint with javascript but not C#. In the js it returns exactly the correct response but returns 403 in C#. It also seems to fail in python. Does anyone know why this might be?
C# Code:
static void Main()
{
Program P = new Program();
P.postRequest();
}
public void postRequest()
{
var apiToken = "MyAPIToken";
var content = "{TheContent}";
using (var client = new WebClient())
{
string uriString = "URL";
client.Headers.Clear();
client.Headers.Add("Content-Type", "application/json");
client.Headers.Add("Ocp-Apim-Subscription-Key", apiToken);
byte[] responseArray = client.UploadData(uriString, Encoding.Default.GetBytes(content));
var response = Encoding.UTF8.GetString(responseArray, 0, responseArray.Length);
}
}