I need to get every user's profile picture from SOAP API. Is it possible to do this?
2 Answers
The User object available from the Salesforce API contains a field called FullPhotoUrl
:
The URL for the user's profile photo if Chatter is enabled. The URL is updated every time a photo is uploaded and reflects the most recent photo.1
You would need to use the query()
method on the API to get all the Users in the system, making sure that your SOQL includes the FullPhotoUrl field in the query.
Remember that if you have more than 500 user records you would need to use the queryMore()
method. A good example of using this pattern in Java and C# can be found in the documentation here.
It isn't currently possible if you just rely solely on the SOAP API. As from Mark's answer, you can perform a SOQL query on User
to get the FullPhotoUrl
.
But then you are stuck. If the user has a photo defined the URL will include the photo ID starting with the 729 keyprefix. However, Photo
isn't currently exposed via the SOAP API. So you can't retrieve it.
Instead you can do an HTTP GET to that URL. Include the Session ID you are using against the SOAP API in the Authorization
head appended onto to Bearer
.
Otherwise you would need to use the Connect REST API to get the photo.