Microsoft.Health.HealthServiceAccessDeniedException: Access is denied.

Proposed Answer Microsoft.Health.HealthServiceAccessDeniedException: Access is denied.

  • Tuesday, February 12, 2013 6:36 PM
     
      Has Code

    Hi I'm trying to do the Eric Gunnerson healthvault tutorials. I get the following error when I try to query and display weights.  I look at some of the previous comments, they don't seem to work for me. I would appreciate your help.

    Server Error in '/website' Application.

    Access is denied.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: Microsoft.Health.HealthServiceAccessDeniedException: Access is denied.

    Source Error:
    Line 28:         HealthRecordFilter filter = new HealthRecordFilter(Weight.TypeId);
    Line 29:         searcher.Filters.Add(filter);
    Line 30:         HealthRecordItemCollection weights = searcher.GetMatchingItems()[0];
    Line 31:         AddHeaderCells(c_tableWeight, "Date", "Weight");
    Line 32:         foreach (Weight weight in weights)

    Source File: c:\Program Files (x86)\Microsoft HealthVault\SDK\DotNet\weighttrackersample2\website\Default.aspx.cs    Line: 30

    Stack Trace:

All Replies

  • Tuesday, February 12, 2013 6:55 PM
     
     
    Did you create a new App (with a new AppID)? Does the app have read access to Weight Measurement?
  • Thursday, February 14, 2013 3:57 PM
     
      Has Code

     Santhosh

    you were right.  I didn't have access to the weight measurement.  I thought i did because I checked on permission to all values.  At this time, i have another problem. After I ran the code again I get this error:

    Server Error in '/website' Application.

    Object reference not set to an instance of an object.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:
    Line 32:         foreach (Weight weight in weights)
    Line 33:         {
    Line 34:             AddCellsToTable(c_tableWeight, weight.When.ToString(),
    Line 35:                                      weight.Value.DisplayValue.ToString());
    Line 36:         }

    Source File: c:\Program Files (x86)\Microsoft HealthVault\SDK\DotNet\weighttrackersample2\website\Default.aspx.cs    Line: 34

    Stack Trace:
    [NullReferenceException: Object reference not set to an instance of an object.]
       HelloWorldPage.Page_Prerender(Object sender, EventArgs e) in c:\Program Files (x86)\Microsoft HealthVault\SDK\DotNet\weighttrackersample2\website\Default.aspx.cs:34
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +93
       System.Web.UI.Control.OnPreRender(EventArgs e) +145
       System.Web.UI.Control.PreRenderRecursiveInternal() +209
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4835
    

  • Monday, February 18, 2013 5:36 PM
     
     Proposed Answer

    Do you have a table named c_tableWeight in your Default.aspx page?

    • Proposed As Answer by Santhosh Pillai Monday, February 25, 2013 11:48 PM
    •  
  • Tuesday, March 05, 2013 1:28 AM
     
     

    Santhosh

     there is a table called c_tableWeight, I thought the problem was because the weight variable was null. Is there anything else you can recommend me