I am trying to add test results via the API and am getting a (400): Bad Request error. Does anyone know what might be wrong with this code? It worked on the old API before it required login credentials.
using (var client = new WebClient())
{
string testResultID = "59";
string BaseURI = "http://testrailurl/index.php?/api/v2/";
string url = string.Format("{0}add_result/{1}", BaseURI, testResultId);
string authInfo = "login@email.com:password";
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
client.Headers["Authorization"] = "Basic " + authInfo;
client.Headers.Add("Accept: application/json");
client.Headers.Add("Content-Type: application/x-www-form-urlencoded");
var data = new NameValueCollection();
data.Add("status_id", testStatus);
data.Add("comment", comment);
var response = client.UploadValues(url, "POST", data);
var str = Encoding.Default.GetString(response);
}