none
how to filter by xpath?

    Question

  • I have two CCD files in my healthvault-ppe.  One is called "sample ccd file" the other is called "sample 2".  I can retrieve both ccd files and can see that the title shows up in a "<note>" tag near the end of the record. Could someone please provide an example of how to filter a Thing so that only the note tags are returned?  (CCD xml files are very large and if there are several of them, it will exceed the AJAX limits, so I cannot retrieve everything and then parse the note tag.)

    I can see here:

    https://platform.healthvault-ppe.com/platform/XSD/method-getthings.xsd

    that there might be one possibility... element name="xpath"

    An xpath that can be specified for filtering on the existence of specific data.

    Unfortunately, I don't see any xpath examples.  Can anyone enlighten me?

    Here is how the php api uses filtering:

        $hv->authenticatedWcRequest(
          'GetThings',
          '3',
          '<group max="30"><filter><type-id>' . $thingId . '</type-id></filter><format><section>core</section></format></group>',
          array('record-id' => $recordId)
        );

        print htmlentities($hv->getRawResponse());

    So I tried inserting an xpath to the filter like this:

    <filter><type-id>' . $thingId . '</type-id><xpath>' .$xpath .'</xpath></filter>

    where I tried the following values of $xpath (with and without the leading slash), non of which worked:

    /common/note

    /data-xml/common/note

    /thing/data-xml/common/note

    The tree view below shows the hierarchy:

    The first two xpaths (with & without the leading slash) produce the following response:

    <response><status><code>0</code></status><wc:info xmlns:wc="urn:com.microsoft.wc.methods.response.GetThings3"><group/></wc:info></response>

    The last xpath (with & without the leading slash) ignores the xpath and returns the entire response.

    • Edited by bluebutton Monday, May 26, 2014 3:55 PM
    Sunday, May 25, 2014 1:29 AM

Answers

  • This xml was generated using the method I recommended in response to one of your other posts. XML API example

    <wc-request:request xmlns:wc-request = "urn:com.microsoft.wc.request">
        <auth>
            <hmac-data algName = "HMACSHA256">2sVTF3zPxeaTCcTh/BD2xF94PWGgFmxuR7CYl510mSw=</hmac-data>
        </auth>
        <header>
            <method>GetThings</method>
            <method-version>3</method-version>
            <record-id>0a3bcbd7-d26e-4d2f-8049-2b579752f23b</record-id>
            <auth-session>
                <auth-token>AiAAAMlJAVVHjCpNjtamDmlzT5+RrxUQakrky9uaE2C6ckd35oiMdsTqzIxpuf3hJ+84K8AAAACnS4FhhKf60+QkwrmeciLPQnMCE6kysHfgNU8jwoWPaKX/d4421AKDO6VipmtFVneHAxofehu/cE0JVFHfquNvlehOw7sjQKKKySQCg33FR9Yn0DhtaXHT54x+T9t3QCcpCOkVicmfLSCHH5CEAr6IAgddcSlzMmh8Y7OL5Vjg9TifiZdI7mF+xC1IGlTbrzIbFVqSvDIGsSjuycTsXeWKTe2bBf2/qdQ2T7HpxWA/uL8Yrl96drebP2Cx6qbK/1kgAAAAuwBfb1ZTdD9hsjfGey6SMoID8UMfDY4eFkuGJe1nQiEgAAAAuwBfb1ZTdD9hsjfGey6SMoID8UMfDY4eFkuGJe1nQiE=</auth-token>
                <offline-person-info>
                    <offline-person-id>XXXXXXXX-3d17-4ac6-bc1d-35bd81a97c48</offline-person-id>
                </offline-person-info>
            </auth-session>
            <culture-code>en-US</culture-code>
            <msg-time>2014-06-13T19:55:01.566Z</msg-time>
            <msg-ttl>1800</msg-ttl>
            <version>HV-NET/1.16.1044.9827 (Microsoft Windows NT 6.2.9200.0; CLR 4.0.30319.34014)</version>
            <info-hash>
                <hash-data algName = "SHA256">Le9yv3P1z48gV1OXNPdz02KbP2TYwXof8hm1LpfoB=</hash-data>
            </info-hash>
        </header>
        <info>
            <group>
                <filter>
                    <type-id>9c48a2b8-952c-4f5a-935d-f3292326bf54</type-id>
                    <thing-state>Active</thing-state>
                </filter>
                <format>
                    <section>core</section>
                    <xml/>
                    <type-version-format>9c48a2b8-952c-4f5a-935d-f3292326bf54</type-version-format>
                </format>
            </group>
        </info>
    </wc-request:request>

    -Sean


    Friday, June 13, 2014 8:03 PM
    Moderator

All replies

  • Check the following blog post. It provides the information you need to make a query for CCD thing types that include only the instance id.

    Improve HealthVault query efficiency with final transforms…

    -Sean

    Thursday, June 05, 2014 8:37 PM
    Moderator
  • Sean,

    The blog post describes a transform code that shows how to do it after the words... "Here’s a transform I wrote to process the unprocessed items response:" but doesn't show how to send it.  Do you have an example of that?

    Thanks,

    Greg

    Wednesday, June 11, 2014 4:48 PM
  • This xml was generated using the method I recommended in response to one of your other posts. XML API example

    <wc-request:request xmlns:wc-request = "urn:com.microsoft.wc.request">
        <auth>
            <hmac-data algName = "HMACSHA256">2sVTF3zPxeaTCcTh/BD2xF94PWGgFmxuR7CYl510mSw=</hmac-data>
        </auth>
        <header>
            <method>GetThings</method>
            <method-version>3</method-version>
            <record-id>0a3bcbd7-d26e-4d2f-8049-2b579752f23b</record-id>
            <auth-session>
                <auth-token>AiAAAMlJAVVHjCpNjtamDmlzT5+RrxUQakrky9uaE2C6ckd35oiMdsTqzIxpuf3hJ+84K8AAAACnS4FhhKf60+QkwrmeciLPQnMCE6kysHfgNU8jwoWPaKX/d4421AKDO6VipmtFVneHAxofehu/cE0JVFHfquNvlehOw7sjQKKKySQCg33FR9Yn0DhtaXHT54x+T9t3QCcpCOkVicmfLSCHH5CEAr6IAgddcSlzMmh8Y7OL5Vjg9TifiZdI7mF+xC1IGlTbrzIbFVqSvDIGsSjuycTsXeWKTe2bBf2/qdQ2T7HpxWA/uL8Yrl96drebP2Cx6qbK/1kgAAAAuwBfb1ZTdD9hsjfGey6SMoID8UMfDY4eFkuGJe1nQiEgAAAAuwBfb1ZTdD9hsjfGey6SMoID8UMfDY4eFkuGJe1nQiE=</auth-token>
                <offline-person-info>
                    <offline-person-id>XXXXXXXX-3d17-4ac6-bc1d-35bd81a97c48</offline-person-id>
                </offline-person-info>
            </auth-session>
            <culture-code>en-US</culture-code>
            <msg-time>2014-06-13T19:55:01.566Z</msg-time>
            <msg-ttl>1800</msg-ttl>
            <version>HV-NET/1.16.1044.9827 (Microsoft Windows NT 6.2.9200.0; CLR 4.0.30319.34014)</version>
            <info-hash>
                <hash-data algName = "SHA256">Le9yv3P1z48gV1OXNPdz02KbP2TYwXof8hm1LpfoB=</hash-data>
            </info-hash>
        </header>
        <info>
            <group>
                <filter>
                    <type-id>9c48a2b8-952c-4f5a-935d-f3292326bf54</type-id>
                    <thing-state>Active</thing-state>
                </filter>
                <format>
                    <section>core</section>
                    <xml/>
                    <type-version-format>9c48a2b8-952c-4f5a-935d-f3292326bf54</type-version-format>
                </format>
            </group>
        </info>
    </wc-request:request>

    -Sean


    Friday, June 13, 2014 8:03 PM
    Moderator
  • Sean,

    I'm asking how to send the request, not what the content of the request is.

    I've been digging deep into the php api code to figure it out.  Here is the key line that sends the request:

    $rawResponse = @file_get_contents($healthVaultPlatform, FALSE, $ctx);

    I have no idea why the '@' is before the command.

    $healthVaultPlatform resolves to 'https://platform.healthvault-ppe.com/platform/wildcat.ashx'

    The request is encoded in $ctx along with a userAuthToken and an authToken. 

    $ctx = stream_context_create($params);

    $params = array(
          'http' => array(
            'method' => 'POST',
            'content' => $xml,
          ),
        );

    $xml looks like a combination of encoded gibberish followed by method name, method version, userAuthToken gibberish, and authToken gibberish.

    I'm guessing I should put your request example xml in for $xml?

    Greg




    • Edited by bluebutton Monday, June 23, 2014 1:30 AM
    Sunday, June 22, 2014 9:37 PM
  • I am not familiar with the PHP code, but from the snippet you have supplied it seems reasonable to assume that you would put your properly formatted XML request in the content parameter as you have surmised.

    -Sean

    Tuesday, June 24, 2014 7:19 PM
    Moderator