API
Version 7.x > API > REST Service showing 401 Unauthorized error when doing a GET Request... View modes: 
User avatar
Member
Member
bdesilva-itravel2000 - 7/5/2013 3:24:51 PM
   
REST Service showing 401 Unauthorized error when doing a GET Request...
Hi,

I have a Kentico Website that we set up at work using ASPX templates and it works pretty well, but now we have a separate ASP.NET site that we want to grab CMS data from certain documents within our Kentico site.

For example, we want to pull out certain images and text in a few of the pages in our Kentico site via a Web Service, so when I found out that there was a REST Web Service available, I was happy that I could access this data easily.

However, your documentation shows only how to setup IIS7 when it comes to configuring REST services, but my development workstation uses Windows XP with IIS 5.1.

So whenever I attempt to run this code from my ASP.NET website:
string url = "http://localhost/OurSite/rest/content/site/currentsite/en-ca/document/OurDocument";
string result = string.Empty;

//System.Net.WebClient wc = new System.Net.WebClient();
//result = wc.DownloadString(url);

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Method = "GET";
WebResponse res = request.GetResponse();
string status = ((HttpWebResponse)res).StatusDescription;
var code = ((HttpWebResponse)res).StatusCode;

Stream stream = res.GetResponseStream();
StreamReader reader = new StreamReader(stream);

string output = reader.ReadToEnd();

I get a 401 unauthorized exception. My IIS has been setup to have "Anonymous Access" unchecked and "Integrated Windows Authentication" checked in the "Authentication Methods" folder.

Why can't I get this to work?

Ben.

User avatar
Member
Member
bdesilva-itravel2000 - 7/5/2013 3:28:09 PM
   
RE:REST Service showing 401 Unauthorized error when doing a GET Request...
Also, in our Kentico website's web config, I have these settings:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />

<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

Please let me know.

Thanks again.
Ben.

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 7/8/2013 9:52:38 AM
   
RE:REST Service showing 401 Unauthorized error when doing a GET Request...
Hi,

The REST service allows only the described authentication methods at devnet.kentico.com/docs/7_0/devguide/rest_authentication

You may also use the authentication hash if the query doesn't change.

Please let me know if I can be of any further assistance.
Regards,
Zdenek

User avatar
Member
Member
bdesilva-itravel2000 - 7/8/2013 10:25:00 AM
   
RE:REST Service showing 401 Unauthorized error when doing a GET Request...
This doesn't help me at all...I have tried with Basic Authentication and Forms Authentication, but maybe it's something I'm configuring wrong on IIS 5.1 as all the examples in the devguide are from IIS 7.

I've also tried the authentication hash from the site manager, but that doesn't work either.

Can you please tell me how to setup IIS 5.1 with either Basic or Forms Authentication in order to get this working?

Thanks,
Ben.

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 7/17/2013 8:49:53 AM
   
RE:REST Service showing 401 Unauthorized error when doing a GET Request...
Hello,

I'm afraid that without the friendly URL extensions feature ensured by the RunAllManagedModulesForAllRequests parameter (available since IIS 7), there are not much options to get this running properly...

Do you have any local machine with IIS7 to test the same scenario?

Regards,
Zdenek