Retrive hosted services through IIS using REST API


  • Hello,

    I am geting 403- forrebidden "The remote server returned an error: (403) Forbidden." while requesting Hosted Services.

    My code for getting list is:

    NameValueCollection RequestHeaders = new NameValueCollection();

    RequestHeaders.Add("x-ms-version", x_ms_version);

    X509Certificate cert = X509Certificate.CreateFromCertFile(CertificatePath);

    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(requestUrl);

    request.Method = "GET";


    if (RequestHeaders != null)




    resp = request.GetResponse();


    The same code is working while I working in windows application.

    Is there any settign that I need to set with IIS? I am working with IIS 7.5.

    Monday, April 04, 2011 5:34 AM

All replies

  • Hi Naresh,

    A similar issue is being reported in the following thread: It seems the user under which IIS is running does not have permission to read certificate data. Since you're reading the certificate from a .cer file, I would suggest you change the permissions on that file so that the user under which IIS is running has necessary permissions to read the data. One quick and dirty way to achieve this would be to grant "Everyone" full permission on that certificate file.

    Hope this helps.


    Gaurav Mantri

    Cerebrata Software


    Monday, April 04, 2011 6:39 AM
  • Hi Gaurav,

    I have tried all options, its not working under IIS.

    If I try without virtual directory then it works finem otherwise I got 404- fiorebbdden error. 

    I have given full access to "EveryOne" to test, but not succeed.



    Naresh Goradara 

    Monday, April 11, 2011 5:53 AM