I am trying to send a PUT
request to update a job on Saucelabs via their API. However, the following code hangs and I am not sure why.
using (var client = new HttpClient())
{
var sessionId = Browser.Driver.GetSessionId();
var uri = new Uri($"https://saucelabs.com/rest/v1/{Configuration.SauceUserName}/jobs/{sessionId}");
var uriWithCred =
new UriBuilder(uri)
{
UserName = $"{Configuration.SauceUserName}",
Password = $"{Configuration.SauceAccessKey}"
}.Uri;
var payload = new StringContent($"{{\"name\":\"{TestMethodName}\"}}", Encoding.UTF8, "application/json");
var request = new HttpRequestMessage
{
Method = HttpMethod.Put,
RequestUri = uriWithCred,
Content = payload
};
var response = client.SendAsync(request).Result;
}
The following cUrl request is successful (redacted credentials, of course).
curl -X PUT -s -u <username>:<access-key>
-d "{\"name\": \"test name\"}"
https://saucelabs.com/rest/v1/<username>/jobs/<job-id>
Why does this request hang and what can I do to make it successful?
For reasons unrelated to the question, I am unable to set the name of the job when setting the capabilities of the WebDriver.