Here is a piece of a PowerShell script, which is similar to C#, that calls a REST API.
I only got it working after adding an empty domain:
$username = "User"
$password = "Password"
$domain = ""
$wc = New-Object System.Net.WebClient
$wc.Credentials = new-object System.Net.NetworkCredential($username, $password, $domain)
$wc.DownloadFile($downloadUrl, $downloadFile)
The full script you can find in:
Fiddling around with the TeamCity REST API[
^]
About
Async: beware that immediately after the await your method will return to the calling method and that the request will not be finished yet, you might have to do some waiting there ...