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

    Question

  • 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?

    Monday, November 12, 2012 8:38 AM

Answers

  • 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
    Monday, November 12, 2012 7:20 PM

All replies

  • 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
    Monday, November 12, 2012 7:20 PM
  • 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!

    Tuesday, November 13, 2012 2:46 AM