I am trying to create a new contact using the google contact api, however its atom feed and XML. There doesn't seem to be a Golang library to do this. I have got to here:
var c models.Category c.Scheme = "http://schemas.google.com/g/2005#kind" c.Term = "http://schemas.google.com/contact/2008#contact" var e models.Email e.DisplayName = "James Bond" e.Address = email e.Primary = "true" var hC models.Entry hC.Title = "Commander" hC.Email = e hC.Category = c buf, _ := xml.Marshal(hC) data := bytes.NewBuffer(buf) client := &http.Client{} req, err := http.NewRequest("POST", "https://www.google.com/m8/feeds/contacts/default/full/", data) If I print out the data object, i.e what is being passed to the google endpoint I can see this: <atom:entry etag="" atom=""> <gd:name> <gd:familyName></gd:familyName> </gd:name> <gd:email address="ja...@bond.com" displayName="James Bond" rel="" primary= "true"></gd:email> <id></id> <gd:im address="" protocol="" primary="" rel=""></gd:im> <gd:name> <gd:givenName></gd:givenName> </gd:name> <edited app=""></edited> <title>Commander</title> <updated></updated> <atom:category scheme="http://schemas.google.com/g/2005#kind" term= "http://schemas.google.com/contact/2008#contact"></atom:category> <gd:name> <gd:fullName></gd:fullName> </gd:name> <content type=""></content> <StructuredPostalAddress rel="" primary=""></StructuredPostalAddress> </atom:entry> That returns a 201 which is expected, however it doesnt seem to create a contact with any data in it. I get this as a response: &{201 Created 201 HTTP/2.0 2 0 map[Vary:[Origin X-Origin] Cache-Control:[ private, max-age=0] X-Content-Type-Options:[nosniff] X-Frame-Options:[ SAMEORIGIN] X-Xss-Protection:[1; mode=block] Etag:[ "RH8_fjVSLyt7I2A9XRFXGU0NRAM."] Date:[Mon, 26 Sep 2016 16:29:35 GMT] Expires :[Mon, 26 Sep 2016 16:29:35 GMT] Server:[GSE] Alt-Svc:[quic=":443"; ma= 2592000; v="36,35,34,33,32"] Content-Type:[application/atom+xml; charset=UTF -8]] 0xc4207cd440 -1 [] false true map[] 0xc4200d05a0 0xc420752420} <?xml version="1.0" encoding="UTF-8"?> <entry gd:etag=""RH8_fjVSLyt7I2A9XRFXGU0NRAM."" xmlns= "http://www.w3.org/2005/Atom" xmlns:batch= "http://schemas.google.com/gdata/batch" xmlns:gContact= "http://schemas.google.com/contact/2008" xmlns:gd= "http://schemas.google.com/g/2005"> <id>http: //www.google.com/m8/feeds/contacts/m...@email.com/base/3177dac09f07838</id> <updated>2016-09-26T16:29:35.146Z</updated> <app:edited xmlns:app="http://www.w3.org/2007/app ">2016-09-26T16:29:35.146Z</app:edited> <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact"/> <title/> <link rel="http://schemas.google.com/contacts/2008/rel#photo" type= "image/*" href="https://www.google.com/m8/feeds/photos/media/m...@email.com /3177dadd09f07838"/> <link rel="self" type="application/atom+xml" href= "https://www.google.com/m8/feeds/contacts/m...@email.com /full/3177dadd09f07838"/> <link rel="edit" type="application/atom+xml" href= "https://www.google.com/m8/feeds/contacts/m...@email.com /full/3177dadd09f07838"/> </entry> My struct looks like this: type Entry struct { XMLName xml.Name `xml:"atom:entry"` Link []Link `xml:"link"` FamilyName string `xml:"gd:name>gd:familyName"` Email Email `xml:"gd:email"` Id string `xml:"id"` Im Im `xml:"gd:im"` GivenName string `xml:"gd:name>gd:givenName"` Edited Edited `xml:"edited"` Title string `xml:"title"` Etag string `xml:"etag,attr"` Updated string `xml:"updated"` Category Category `xml:"atom:category"` FullName string `xml:"gd:name>gd:fullName"` PhoneNumber []PhoneNumber `xml:"gd:phoneNumber"` Content Content `xml:"content"` Atom string `xml:"atom,attr"` StructuredPostalAddress StructuredPostalAddress `xml:gdstructuredPostalAddress` } So as far as I can see, the contact looks like its being created (the 201 response) however as the reponse has no content i don't think it is being created, and this is backed up by when I take the ID from the response and use the Google API playground it doesn't seem to have any content. Any help greatly appreciated. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.