chitra
chitra

Reputation: 556

The remote server returned an error: (401) Unauthorized in NopCommerce

I have implemnted plugin in Nopcommerce 3.30. That plugin's controller action method contains:

System.Net.HttpWebRequest objRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(idiUrl);
        objRequest.Method = "GET";
        objRequest.ContentType = "application/x-www-form-urlencoded";
        objRequest.AllowAutoRedirect = true;
        objRequest.Credentials = CredentialCache.DefaultCredentials;
        objRequest.KeepAlive = false;
        objRequest.Timeout = 300000;

After this line,

System.Net.HttpWebResponse objResponse = (System.Net.HttpWebResponse)objRequest.GetResponse()

I get error i.e.,

The remote server returned an error: (401) Unauthorized. The details for the log entry.

Full message: System.Net.WebException: The remote server returned an error: (401) Unauthorized. at System.Net.HttpWebRequest.GetResponse()

Help me please to solve this issue.

Thanks.

Upvotes: 1

Views: 1865

Answers (1)

wooncherk
wooncherk

Reputation: 1364

What is idiUrl. Does it work if you visit the URL directly in browser? I think it requires authentication / authorization, and you did not provide that since you are using DefaultCredentials.

Upvotes: 1

Related Questions