Calling WEB API with basic authentication in C#
问题 I have a working WEB API that I wrote, and I added basic authentication to the API (username is "testing", password is "123456"). However, when trying to call that API from my web form, I keep getting the "(401) Unauthorized" message. What should I change in the web code to call the API successfully? string url = String.Format("http://example.com"); //here I have the correct url for my API HttpWebRequest requestObj = (HttpWebRequest)WebRequest.Create(url); requestObj.Method = "Get";