使用 userid 和 pwd base64 身份验证访问 .Json URL

Access .Json URL with userid and pwd base64 authentication

我正在尝试访问可以下载 .Json 的网站,但该网站有用户 ID 和 PWD。我有它的凭据并且该站点正在使用基本身份验证(基本身份验证(base64 编码密码))我不知道我是否走在正确的轨道上,或者我是否可以通过其他方式使用用户 ID 和密码访问该站点?

using (var webClient = new System.Net.WebClient())
    {
       webClient.Credentials = new NetworkCredential("username", "pwd");
       var json = webClient.DownloadString("https://tracking.com/delivery/api/fetch-transactions?fromDate=2020-01-01");
       List<Example> list = JsonConvert.DeserializeObject<List<Example>>(json);
    }

我得到的错误是:

看起来它没有用用户 ID 和密码打开 url...

这个对我有用:

string credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(username + ":" + password));

webClient.Headers[HttpRequestHeader.Authorization] = "Basic " + credentials;