Download a file from Microsoft HealtVault.

Jul 17, 2011 at 8:23 PM
Edited Jul 17, 2011 at 8:35 PM

Hi,

Is there a code snippet which can be used to download a File from Microsoft Health Vault in the Android platform? Also the code available on How to do for uploading file, does it support Android?

Sana.

Coordinator
Jul 18, 2011 at 5:07 PM

Hi Sana,

There isn't an example using the Java sdk.  Using the Android library you will be creating and parsing the XML requests directly.  Here is a blog post describing the XML format necessary for blob support:  http://blogs.msdn.com/b/ericgu/archive/2011/05/24/dealing-with-blob-data-in-healthvault-xml.aspx

--Rob

Jul 18, 2011 at 9:36 PM
Edited Jul 18, 2011 at 10:22 PM

So with the blog, I followed it step by step and added the new extra section.

 

String infoFile = "<info><group max=\"100\"><filter><type-id>" +
        File.TYPE +
        "</type-id></filter><format><section>core</section><section>blobpayload</section> " +
        "<xml/></format></group></info>";

But it gives me a xml parse error saying that section element is invalid and bobpayload is invalid according to its datatypes.....

 

Also in the documentation under "http://developer.healthvault.com/sdk/docs/urn.com.microsoft.wc.methods.GetThings.ThingSectionSpec.1.html" I don't see any bobpayload enum at all. Am I missing something here?

 

Just to add to the bloggers curiosity, when I add the filter "<section>otherdata</section>" it gives me the response in

<data-other content-type="text/plain" content-encoding="base64">***Content here is in Base64 format***</data-other>

which I encode it back to my format.

 

So I would like to know which is a cleaner method of doinf stuff? the blog or should I go ahead with "otherdata"?

Coordinator
Jul 18, 2011 at 11:34 PM

The blobpayload section was added in GetThings version 3.  It's best to use the latest versions of the methods:  GetThings v3, PutThings v2.

--Rob

Jul 19, 2011 at 3:34 PM
Edited Jul 19, 2011 at 4:28 PM

So I guess for uploading I will be using PutThings version 2.

 

I guess it should have been updated in the blog with version 3. Anyways thanks a lot for fetching data it worked perfect!

 

Thanks a lot, the documentation of HealthVault has to be updated! Can anyone voluntarily update them?

Jul 17, 2012 at 12:22 PM
Edited Jul 17, 2012 at 4:51 PM

In case anyone is reading these older discussions, here are the steps required to get this working on android; just add a few lines to the code for the "Weighter" sample app as indicated below:

@SuppressWarnings("unchecked")
public static String getRawXml_n_BinaryData(Record record, String HV_TYPE) {
    SimpleRequestTemplate template = new SimpleRequestTemplate(
	HealthVaultService.getInstance().getConnection(),
        record.getPersonId(),
        record.getId());

    String info = "<info>" +
    "<group max=\"25\">" +
        "<filter>" + 
            "<type-id>" + HV_TYPE + "</type-id>" + 
        "</filter><format>" + 
            "<section>core</section>" +
            "<section>blobpayload</section>" +
            "<xml/>" + 
            "<type-version-format>" + HV_TYPE + "</type-version-format>" +
            "<blob-payload-request>" +
                "<blob-format>" +
                    "<blob-format-spec>inline</blob-format-spec>" +
                "</blob-format>" +
            "</blob-payload-request>" +						
        "</format>" + 
    "</group>" +
"</info>";

    Request request = new Request();
    request.setMethodName("GetThings");
    request.setMethodVersion("3");

(Note that you don't need to mess around with fancy imports or changing the method name; just use "3" for the method version)

HTH

Coordinator
Jul 19, 2012 at 9:18 PM

Thanks for adding to the knowledge here!

Jul 5, 2013 at 10:58 AM
I am using the following Health Vault iOS SDK :
https://github.com/microsoft-hsg/HVMobile_VNext?source=c

Can someone help me to download a file from Health Vault using the SDK API's?