HealthService() sets up a connect to /health.  If you're going to work
with /h9, you need to keep the authFactory (which uses the correct
service 'weaver'), or use Service():
Service service = new Service("weaver", "exampleCo-exampleApp-1");

It doesn't look like you can set the service name property.
The Service.ServiceIdentifier Property doesn't have a setter:
http://google-gdata.googlecode.com/svn/docs/folder54/P_Google_GData_Client_Service_ServiceIdentifier.htm

Frank may have a better soln there, but I would keep the authFactory:
HealthService service = new HealthService
(authFactory.ApplicationName);
GAuthSubRequestFactory authFactory = new GAuthSubRequestFactory
("weaver", "exampleCo-exampleApp-1");
service.RequestFactory = authFactory;

When you switch to /health, you can just use:
HealthService service = new HealthService("exampleCo-exampleApp-1");
--
Lastly, also have a few statements like:
service.Insert(new Uri("https://www.google.com/h9/feeds/register/ui/
entry.Content.Content"), newNotice);
HealthQuery profileQuery = new HealthQuery("https://www.google.com/h9/
feeds/profile/ui/profileID");

when you really mean:
service.Insert(new Uri("https://www.google.com/h9/feeds/register/ui/";
+ entry.Content.Content), newNotice);
HealthQuery profileQuery = new HealthQuery("https://www.google.com/h9/
feeds/profile/ui/" + profileID);


Eric


On Mar 9, 2:16 pm, Aidan P Calnan
<[email protected]> wrote:
> I have removed the authSub code. i can see that i am getting a profile ID 
> because the code:
> foreach (AtomEntry entry in feed.Entries)
>             {
>                 Console.WriteLine("\tProfile " + entry.Title.Text + " has ID: 
> " + entry.Content.Content);
>             }
> gives output:
> Profile aidan.p.calnan has ID: 3SErPmRmnTw
>
> It is the insert line that is giving the request exception with the following 
> response string:
> <HTML>
> <HEAD>
> <TITLE>Token invalid</TITLE>
> </HEAD>
> <BODY BGCOLOR="#FFFFFF" TEXT="#000000">
> <H1>Token invalid</H1>
> <H2>Error 401</H2>
> </BODY>
> </HTML>
>
> i have tried it with that particular profileID and using 
> entry.Content.Content. it is always giving the same error with the insert. my 
> code is shown below:
>
> private void Login_Click(object sender, System.EventArgs e)
>         {
>             this.service.setUserCredentials(this.Username.Text, 
> this.Password.Text);
>             this.authToken = this.service.QueryAuthenticationToken();
>             //this.Close();
>
>             //string pid = findValue(args, "pid", null);
>             //string pname = findValue(args, "pname", null);
>
>             HealthService service = new 
> HealthService("exampleCo-exampleApp-1");
>             service.setUserCredentials("[email protected]", 
> "jakaveli");
>
>             AtomEntry newNotice = new AtomEntry();
>             newNotice.Title.Text = "A test message";
>             newNotice.Content.Content = "This is a test message.";
>             // Set the content type if you're using HTML in your message body
>             newNotice.Content.Type = "html";
>             String ccrXmlString = @"<ContinuityOfCareRecord 
> xmlns='urn:astm-org:CCR'>      
>                                         <Body>        
>                                             <Problems>          
>                                                 <Problem>            
>                                                     <DateTime>              
>                                                         <Type>                
>                                                             <Text>Start 
> date</Text>              
>                                                         </Type>              
>                                                         
> <ExactDateTime>2007-04-04T07:00:00Z</ExactDateTime>            
>                                                     </DateTime>            
>                                                     <DateTime>              
>                                                         <Type>                
>                                                             <Text>Stop 
> date</Text>              
>                                                         </Type>              
>                                                         
> <ExactDateTime>2008-07-20T07:00:00Z</ExactDateTime>            
>                                                     </DateTime>            
>                                                     <Description>             
>  
>                                                         <Code>                
>                                                             
> <Value>346.80</Value>                
>                                                             
> <CodingSystem>ICD9</CodingSystem>                
>                                                             
> <Version>2004</Version>              
>                                                         </Code>            
>                                                     </Description>            
>                                                     
> <Status><Text>Active</Text></Status>            
>                                                     <Source>              
>                                                         <Actor>               
>  
>                                                             <ActorID>Harris 
> Smith</ActorID>                
>                                                             <ActorRole>       
>            
>                                                                 
> <Text>Treating clinician</Text>                
>                                                             </ActorRole>      
>         
>                                                         </Actor>            
>                                                     </Source>          
>                                                 </Problem>        
>                                             </Problems>      
>                                         </Body>  
>                                     </ContinuityOfCareRecord>";
>             XmlDocument ccrDoc = new XmlDocument();
>             ccrDoc.LoadXml(ccrXmlString);
>             newNotice.ExtensionElements.Add(new 
> XmlExtension(ccrDoc.DocumentElement));
>             //service.Insert(new 
> Uri("https://www.google.com/health/feeds/register/default";), newNotice);
>             //service.Insert(new 
> Uri("https://www.google.com/h9/feeds/register/ui/profileID";), newNotice);
>
>             //if (pid == null && pname != null)
>             //{
>             //    // need to find the ID first.
>             //    // so we get the list feed, find the name in the TITLE, and 
> then
>             //    // get the ID out of the content field
>             //    HealthFeed feed = service.Query(new 
> HealthQuery(HealthQuery.ProfileListFeed));
>             //    foreach (AtomEntry entry in feed.Entries)
>             //    {
>             //        if (entry.Title.Text == pname)
>             //        {
>             //            pid = entry.Content.Content;
>             //        }
>             //    }
>             //}
>
>             HealthFeed feed = service.Query(new 
> HealthQuery(HealthQuery.ProfileListFeed));
>             Console.WriteLine("Feed =" + feed);
>             foreach (AtomEntry entry in feed.Entries)
>             {
>                 Console.WriteLine("\tProfile " + entry.Title.Text + " has ID: 
> " + entry.Content.Content);
>                 //service.Insert(new 
> Uri("https://www.google.com/h9/feeds/register/ui/3SErPmRmnTw";), newNotice);
>                 service.Insert(new 
> Uri("https://www.google.com/h9/feeds/register/ui/entry.Content.Content";), 
> newNotice);
>             }
>             //return;
>
>             try
>             {
>                 //service.Insert(new 
> Uri("https://www.google.com/h9/feeds/register/default";), newNotice);
>                 //service.Insert(new 
> Uri("https://www.google.com/h9/feeds/register/ui/profileID";), newNotice);
>                 service.Insert(new 
> Uri("https://www.google.com/h9/feeds/register/ui/3SErPmRmnTw";), newNotice);
>             }
>             catch (GDataRequestException err)
>             {
>                 MessageBox.Show(err.ResponseString);
>                 //MessageBox.Show(err.);
>                 //err.Response.GetResponseStream();
>                 //err.Response.GetType();
>             }
>
>             //HealthQuery profileQuery = new 
> HealthQuery("https://www.google.com/health/feeds/profile/default";);
>             //HealthQuery profileQuery = new 
> HealthQuery("https://www.google.com/h9/feeds/profile/default";);
>             HealthQuery profileQuery = new 
> HealthQuery("https://www.google.com/h9/feeds/profile/ui/profileID";);
>             profileQuery.Digest = true;
>             // returns a single <atom:entry> containing the user's CCR
>             try
>             {
>                 HealthFeed feed2 = service.Query(profileQuery);
>                 foreach (HealthEntry entry in feed2.Entries)  
>                 {    
>                     XmlNode ccr = (XmlExtension) 
> entry.FindExtension("ContinuityOfCareRecord", "urn:astm-org:CCR");
>                     if (ccr != null)    
>                     {
>                         
> System.Web.HttpContext.Current.Response.Write("<pre>");  
>                         StringWriter sw = new StringWriter();      
>                         XmlTextWriter xw = new XmlTextWriter(sw);      
>                         xw.Formatting = Formatting.Indented;      
>                         ccr.WriteTo(xw);
>                         
> System.Web.HttpContext.Current.Response.Write(HttpUtility.HtmlEncode(sw.ToString()));
>                         
> System.Web.HttpContext.Current.Response.Write("</pre>");
>
>                         Console.WriteLine("ccr is not null");
>                     }  
>                 }
>             }
>             catch (GDataRequestException err)
>             {
>                 MessageBox.Show(err.ResponseString);
>                 }
>         }
>
> thanks,
> Aidan
>
> ----- Original Message -----
> From: "Frank Mantek" <[email protected]>
> To: [email protected]
> Sent: Monday, 9 March, 2009 13:32:58 GMT +00:00 GMT Britain, Ireland, Portugal
> Subject: [Google-Health-API] Re: GDataRequestException in .Net
>
> To do client login, you only need to do this:
>
> >            this.service.setUserCredentials(this.Username.Text,
>
> As far as i see in the snippet, you are not using the authtoken  
> returned by queryauthenticationtoken, and you are not doing authsub  
> authentication, so get rid of the 2nd snippet completely.
>
> Frank
>
> On Mar 9, 2009, at 2:19 PM, Aidan P Calnan wrote:
>
> > i am trying to do ClientLogin, should i get rid of the second bit of  
> > code you posted there?
>
> > thanks,
> > Aidan
> > ----- Original Message -----
> > From: "Frank Mantek" <[email protected]>
> > To: "Google Health Developers" <[email protected]
>
> > Sent: Monday, 9 March, 2009 13:09:50 GMT +00:00 GMT Britain,  
> > Ireland, Portugal
> > Subject: [Google-Health-API] Re: GDataRequestException in .Net
>
> > I am trying to make sense of the code you are posting....
>
> > in the first 3 lines you do:
> >            this.service.setUserCredentials(this.Username.Text,
> > this.Password.Text);
> >            this.authToken = this.service.QueryAuthenticationToken();
> >            this.Close();
>
> > that is code borrowed
>
> ...
>
> read more »
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Health Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/googlehealthdevelopers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to