Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.
Throws “Microsoft.Health.HealthServiceAccessDeniedException”.Why?

Answered Throws “Microsoft.Health.HealthServiceAccessDeniedException”.Why?

  • Monday, November 12, 2012 8:38 AM
     
     

    I compile and run "ClientSamples" provided by HealthVault SDK("Program Files\Microsoft HealthVault\SDK\DotNet\ClientSamples") and upload weight data successfully. But when I want to upload blood pressure data through modifying code,the Visual Studio 2008 reminds me that the "Microsoft.Health.HealthServiceAccessDeniedException" occurs.

    The code of uploading weight data:

    Weight weight = new Weight();
    weight.Value = new WeightValue(weightValue);
    accessor.NewItem(weight);

    The code of uploading blood pressure data:

    BloodPressure bloodPressure = new BloodPressure();
    bloodPressure.Systolic = 120;
    bloodPressure.Diastolic = 80;
    bloodPressure.Pulse = 75;
    bloodPressure.When = new HealthServiceDateTime();
    accessor.NewItem(bloodPressure);

    Common code:

    _healthClientApplication = HealthClientApplication.Create(_applicationId, _masterApplicationId);

    HealthClientApplication.StartApplicationCreationProcess();

    HealthClientApplication.StartUserAuthorizationProcess();

    HealthClientAuthorizedConnection connection = HealthClientApplication.CreateAuthorizedConnection(PersonId);

    HealthRecordAccessor accessor = new HealthRecordAccessor(connection, RecordId);

    Why the exception occurs and how to solve it?

All Replies

  • Monday, November 12, 2012 7:20 PM
     
     Answered

    Hi Kevin,

    The sample application only requests read/write access for Height and Weight measurements, Custom Data, and Fitness data types. This is why you get access denied when you try to write Blood Pressure value.

    You can see the data types that the application requests when you provision the app.

    Thanks
    Santhosh

     

    • Marked As Answer by Kevin00000000 Tuesday, November 13, 2012 2:46 AM
    •  
  • Tuesday, November 13, 2012 2:46 AM
     
     

    Thank you!

    Because I use the predefined MaseterApplicationId in the Sample,and it has only access for Height and Weight measurements, Custom Data, and Fitness data types.Once I register a new MaseterApplicationId and set its access for blood pressure,upload successfully!