Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to retrieve all the profile pictures of all the people in my org. How would I do that?

share|improve this question
up vote 5 down vote accepted

If you have access to the REST API, then you can use the following python code:

import json
import requests

query = "SELECT+id,+FullPhotoUrl,+LastName+FROM+User"
query_url = ''
#access_token would be the access token retrieved from the OAuth process.
headers = {'Authorization': 'Bearer ' + access_token}

#get list of all users (id, photo url, and last name)
r = requests.get(query_url + query, headers=headers)
if r.status_code != 200:
    print r.content
    resp = json.loads(r.content)
    print resp.get('records')
    #for each user in the result set
    for user in resp.get('records'):
        photo_url = user.get('FullPhotoUrl')
        r = requests.get(photo_url, headers=headers)
        print r.status_code
        if r.status_code == 200:
            filename = '/jmm/pics/{}.jpg'.format(user.get('LastName'))
            chunk_size = 500
            #download the image and save it to your harddrive
            with open(filename, 'wb') as fd:
                for chunk in r.iter_content(chunk_size):
            print 'head between your knees we\'re all gonna die!'
            print r.status_code
            print r.content
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.