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 from the login dialog class i assume. this indicates client login. But, you close the form there? Later you do: GAuthSubRequestFactory authFactory = new GAuthSubRequestFactory("weaver", "exampleCo-exampleApp-1"); HealthService service = new HealthService (authFactory.ApplicationName); service.RequestFactory = authFactory; service.setUserCredentials("user", "pwd"); If you want to do AuthSub authentication, you need to have an authsub token, but again, you set up username and password..... That's probably the reason you are getting an 403 with an unknown authorization header. So what are you trying to do ? ClientLogin or AuthSub? Frank On Mar 6, 10:12 pm, Aidan P Calnan <[email protected]> wrote: > The response string is: > "<HTML>\n<HEAD>\n<TITLE>Unknown authorization header</TITLE>\n</HEAD>\n<BODY > BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\">\n<H1>Unknown authorization > header</H1>\n<H2>Error 401</H2>\n</BODY>\n</HTML>\n" > > Thanks, > Aidan > > ----- Original Message ----- > From: "Frank Mantek" <[email protected]> > To: [email protected] > Sent: Friday, 6 March, 2009 12:57:11 GMT +00:00 GMT Britain, Ireland, Portugal > Subject: [Google-Health-API] Re: GDataRequestException in .Net > > what's the contents of the ResponseString of the Exception? > > Frank > On Mar 6, 2009, at 3:20 AM, Aidan P Calnan wrote: > > > thanks Frank, > > > I added that to my code and i now have GDataRequestException on the > > line: > > HealthFeed feed = service.Query(new > > HealthQuery(HealthQuery.ProfileListFeed)); > > > full code is below, thanks to anyone who can help > > > 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"); > > > GAuthSubRequestFactory authFactory = new > > GAuthSubRequestFactory("weaver", "exampleCo-exampleApp-1"); > > HealthService service = new > > HealthService(authFactory.ApplicationName); > > service.RequestFactory = authFactory; > > 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); > > } > > 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); > > } > > 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); > > } > > } > > > Regards, > > Aidan > > ----- Original Message ----- > > From: "Frank Mantek" <[email protected]> > > To: "Google Health Developers" <[email protected] > > > Sent: Thursday, 5 March, 2009 13:32:23 GMT +00:00 GMT Britain, > > Ireland, Portugal > > Subject: [Google-Health-API] Re: GDataRequestException in .Net > > > When you look into the main.cs file above, it has an option to LIST > > the users profile feeds. When you follow that codepath, this is code > > you could use to populate a listbox picker for a user to choose his > > profile with. > > > That code here: > > > 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); > > } > > return; > > > then gives you a profile name and a profile id. > > > Frank > > > On Mar 5, 1:09 pm, Aidan P Calnan > > <[email protected]> wrote: > >> Thanks Frank, > > >> I do need to know what profile i am working with but am unsure on > >> how to get the profileID. what exactly did u mean by "So you either > >> had a picker before that has choosen the name or some UI like > >> that." Also you say "So remember the name or > > ... > > read more » -------------------------------------------------------------------------- Ta an r-phost seo fe reir an tseanta / na seanta seo leanas ata le fail ag This e-mail is subject to the following disclaimer(s) available at http://www.ittralee.ie/EmailDisclaimer.html Smaoinigh ar an dtimpeallacht sula bpriontaileann tu an r-phost seo Please consider the environment before printing this e-mail -------------------------------------------------------------------------- --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
