Error Code 67 - Unique Identifier

Feb 5, 2010 at 5:14 AM

Hi all,

I am working on making a sample application run. I successfully created a Connection instance.  I then try to create the HVAccess and call the send() method with the following request (the offlineUserId and the recordId have been replaced):

Request request = new Request();
request.setMehtodName("GetThings");
request.setOfflineUserId("99999999-9999-9999-9999-999999999999");
request.setRecordId("88888888-8888-8888-8888-888888888888");
request.setInfo(requestXml); 

private App() {
    
     String requestXml = this.generateRequestXml();
     Request request = this.generateRequest(requestXml);
    
     Connection connection = ConnectionFactory.getConnection();
     connection.authenticate(true);
     HVAccessor accessor = new HVAccessor();
     accessor.send(request, connection);
     Response response = accessor.getResponse();
    }
    
    private String generateRequestXml() {
    
     StringBuilder requestXml = new StringBuilder();
     requestXml.append("<info><group>");
     requestXml.append("<filter><type-id>bd0403c5-4ae2-4b0e-a8db-1888678e4528</type-id></filter>");
     requestXml.append("<format><section>core</section><section>otherdata</section><xml/></format>");
     requestXml.append("</group></info>");
     return requestXml.toString();
    }
    
    private Request generateRequest(String requestXml) {
    
     Request request = new Request();
     request.setMethodName("GetThings");
    
     // I can't figure out the offline user id for the PPE though...
     //request.setOfflineUserId("b57d2b7e-12a0-4930-97b8-d24423de7795");
     request.setOfflineUserId("f954f81d-dc34-4f52-a4dd-d31c5e6820d3");
    
     // This is the record id for the PPE.
     request.setRecordId("91a1cb84-bf0e-4a9e-bad3-77418ca9124d");
     request.setInfo(requestXml);
    
     return request;
   

When I call the send with this Request instance, I get back the following error:

<?xml version="1.0" encoding="utf-8"?><response><status><code>67</code><error><message>The unique identifier 9999999-9999-9999-9999-999999999999 for the person cannot be found.</message></error></status></response>

Apparently, I am using the incorrect OfflineUserId.  However, I'm not sure which userId or personId I am supposed to be using.  I tried using the personId from the Application Manager and I've tried using others, but to no success.  Can someone please point me in the right direction about where I am going wrong here?

Thanks,

- Darin

 

 

Coordinator
Feb 8, 2010 at 6:11 PM

Hi lpdwilco,

PersonIds are application specific.  Once somebody has authorized an application, that application can obtain their PersonId.  If you have a user-auth-token from HV, you can use that to call GetPersonInfo.  The application specific PersonId, as well as the application specific recordIds will be contained in the response.  Have a look at the UI samples for how this works.

If you are motivated, you can download the latest source which contains more examples.

--Rob

 

Feb 17, 2010 at 4:11 AM

Thanks Rob.  I was able to look at the new examples and extract what was needed from there.

Feb 25, 2010 at 9:34 PM

Hi Rob,

    Can I use <label>Client token (GUID) to set OfflineUserId on Request for invoking GetPerson Method?</label>

<label>    The reason why m'I asking is I'm trying to connect to Healthvault through mobile application and hence can't use browser and can't get UserAuthenticationToken.</label>

<label>    So I'm trying to set OfflineUserId on Request class to invoke GetPerson method, unfortunately I don't know what should be used as OfflineUserId.</label>

<label>    Could you please help me with this?</label>

<label>Thanks,</label>

<label></label><label>Sri</label>

<label></label>

<label></label>

<label>  </label>

<label></label>

<label>  </label>

 

Feb 25, 2010 at 9:35 PM

Hi Rob,

    Can I use <label>Client token (GUID) to set OfflineUserId on Request for retrieving GetPerson Method?</label>

<label>    The reason why m'I asking is I'm trying to connect to Healthvault through mobile application and hence can't use browser and get UserAuthenticationToken.</label>

<label>    So I'm trying to set OfflineUserId on Request class to invoke GetPerson method, unfortunately I don't know what should be used as OfflineUserId.</label>

<label>    Could you please help me with this?</label>

<label>Thanks,</label>

<label></label><label>Sri</label>

Feb 28, 2010 at 12:38 AM

You can use a "connect request" to access a user's record in offline-mode:

SimpleRequestTemplate srt = new SimpleRequestTemplate(ConnectionFactory.getConnection());

String externalId = "" + System.currentTimeMillis();
CreateConnectRequestRequest request = new CreateConnectRequestRequest();
request.setFriendlyName("Bob Smith");
request.setExternalId(externalId);
request.setQuestion("question");
request.setAnswer("answer");

CreateConnectRequestResponse response = (CreateConnectRequestResponse)srt.makeRequest(request);
String identityCode = response.getIdentityCode();


Then, show the user the identity-code and ask them to go to https://account.healthvault-ppe.com/patientwelcome.aspx to enter the code and approve the application.

When the user approves the application using the identity-code, your application can retrieve their record-id and person-id using the external-id you entered in the initial request:

SimpleRequestTemplate srt = new SimpleRequestTemplate(ConnectionFactory.getConnection());

GetAuthorizedConnectRequestsRequest request = new GetAuthorizedConnectRequestsRequest();

GetAuthorizedConnectRequestsResponse response = (GetAuthorizedConnectRequestsResponse)srt.makeRequest(request);
for (ConnectRequest cr : response.getConnectRequest()){
    if (cr.getExternalId().equals(externalId)){
        String personId = cr.getPersonId();
        String recordId = cr.getRecordId();
        //save these somewhere
    }
}

 

Feb 28, 2010 at 1:30 AM

Hi mangstadt, Thank you very much for your reply. I really appreciate that. I will try it out today. I have another question. I was trying to create Child record using AddApplication method and I'm getting "The authentication token element of the request is required for this method." I'm setting app-auth-required to false but still I'm getting this error. Could you please help me with this?

Thanks, talktosri.

 

Feb 28, 2010 at 1:41 AM

talktosri,

I don't know how to create a child record, but I doubt AddApplication is the method you'd want to use!  It appears that AddApplication is the equivalent of creating a new application from config.healthvault-ppe.com

 

Feb 28, 2010 at 2:02 AM

Hi mangstadt,  then I will try to see if there is an altenative to add child records. But I have a question in the solution you gave me intially. Since I'm writing code for mobile application to authenticate a user, is there a way I can do it without redirecting the user to https://account.healthvault-ppe.com/patientwelcome.aspx. I cannot use browser.

 My requirement is : Authenticate a user (cannot use browser) and allow him to add records in healthvault.

I would greatly appreciate your help.

Thanks, talktosri.

  

Feb 28, 2010 at 2:27 AM

The user must go to their HealthVault account (through a browser) in order to approve your application.  There's no other way to do this that I know of..

Mar 16, 2010 at 8:54 PM

Hi mangstadt,  I was able to authenticate an application as mentioned above, but when I'm trying to call GetAuthorizedConnectRequests method, the response is not returning any records.

I created 3users and authenticated my application by those 3users. Still the response is empty. Could you please help me where I went wrong.

Mar 17, 2010 at 2:30 PM
Did you authenticate those three users by creating a connect request (CreateConnectRequest method) for each one? If not, then it makes sense that the GetAuthorizedConnectRequests response was empty. Can you post some of your code?
Mar 17, 2010 at 3:28 PM

Yes I did Authenticate them using CreateConnectRequest method

I exactly did the same way as you mentioned above, my code is just as same as yours.

 

 

String externalId = "" + System.currentTimeMillis();
Info creatConnectionReq = new Info();
creatConnectionReq.setFriendlyName(userName);
creatConnectionReq.setExternalId(externalId);
creatConnectionReq.setQuestion(question);
creatConnectionReq.setAnswer(answer);
com.sensei.phi.methods.jaxb.createconnectrequest.response.Info creatConnectionResp = (
com.sensei.phi.methods.jaxb.createconnectrequest.response.Info)srt.makeRequest(creatConnectionReq);
String identityCode = creatConnectionResp.getIdentityCode();

 

 

Mar 17, 2010 at 3:30 PM

I was able to retrieve those 3users using GetAuthorizedPeople method, but I couldn't get any records using GetAuthorizedConnectRequests method

Mar 17, 2010 at 4:17 PM
Edited Mar 17, 2010 at 4:17 PM
When you created the connect requests, did you save the external-id of each request? If you used my code exactly, but didn't save the external-id, this is probably why you don't see any approved connect requests.

There's a problem with using GetAuthorizedPeople to get the person-id and record-id of a newly approved record: you don't know which newly approved HealthVault record belongs to which user in your application. For example, you authorized three users, but how do you know which HealthVault record belongs to which user of your application? Connect requests don't have this problem because you use the external-id to map the person-id and record-id of the HV record to the user of your application (because your application is supposed to save the external-id).