我是rest API和通过.NET调用它们的新手。
我有一个API:https://sub.domain.com/api/operations?param=value¶m2=value
API的注释说,要进行授权,我需要使用基本访问身份验证-我该如何做?
我目前有以下代码:
WebRequest req = WebRequest.Create(@"https://sub.domain.com/api/operations?param=value¶m2=value");
req.Method = "GET";
//req.Credentials = new NetworkCredential("username", "password");
HttpWebResponse resp = req.GetResponse() as HttpWebResponse;
然而我收到了401未授权的错误。
我错过了什么?如何使用基本访问权限进行API调用?