Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6002809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:01:54+00:00 2026-05-23T01:01:54+00:00

I am trying to write a ruby app to update Google Contact Photos but

  • 0

I am trying to write a ruby app to update Google Contact Photos but I cant get the upload working. Im not sure if I have misunderstood the Google API but this is what I have so far:

Net::HTTP.start(URI.parse(image_element.attributes['href']).host) do |http|
  response, body = http.put(URI.parse(image_element.attributes['href']).path, data, {'If-Match' => '*', 'content-type'=>'image/*'})
end

The Google Data API says:

Every contact has a photo link
element. It has the form:

href=’https://www.google.com/m8/feeds/photos/media/liz%40gmail.com/c9012de’
gd:etag='”KTlcZWs1bCp7ImBBPV43VUV4LXEZCXERZAc.”‘>

That element appears whether the
contact has an associated photo or
not. If the contact does have a photo,
then the element contains a gd:etag
attribute specifying an ETag for the
photo. If the contact has no photo,
then there’s no gd:etag attribute, and
the href attribute provides the URL to
use to add a photo to the contact.

To add or update a photo given the
element shown above, send a new
photo with a PUT command to the URL:
https://www.google.com/m8/feeds/photos/media/liz%40gmail.com/c9012de.
Remember to set a proper “image/*”
Content-Type header.

To delete a photo, send an HTTP DELETE
request to the same URL.

When updating or deleting a photo,
send the photo’s ETag in the If-Match
header of the HTTP request.
Alternatively, use If-Match: * to
update or delete regardless of whether
you have the latest version of the
photo.

Can anyone see where I am going wrong?

UPDATE AND ANSWER:
I’ve managed to get this working with some help from StackOverflow and a mate. Basically what was wrong was the incorrect MIME type being set (see below) but also I wasn’t authenticated properly with Google for the PUT request. What I was trying to write was a Script that updates any missing Google Contact Photos with images from Gravatar (where possible). Once I got it working it worked great: managed to match about 2 – 3 dozen contacts. I wrote a blog post on the script in case anyone wants to run it also: http://ashleyangell.com/2011/06/ruby-script-to-import-google-contact-photos-from-gravatar/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:01:55+00:00Added an answer on May 23, 2026 at 1:01 am

    I’ve never used the Google Data API myself, but try setting the Content-Type header to, for example, image/jpeg, rather than just image/*.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write an app using Ruby on Rails and I'm trying to
Ruby 1.9.1, OSX 10.5.8 I'm trying to write a simple app that parses through
I am trying to write an interface between RSPEC (ruby flavoured BDD) and a
I'm trying to write an import rakefile for Redmine. It uses ruby on rails.
I'm trying to write some PHP to upload a file to a folder on
I have done some work with Ruby on Rails but am still not comfortable
Okay, I'm trying to write a ruby simulation of my grandmother. I can't quite
Not sure on my Ruby syntax here. I want to define a method that
Trying to get Rails up on ubuntu, and I’m having trouble installing sqlite3-ruby –
I'm working on a fairly complicated app and am trying to figure out how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.