How to Integrate SuccessFactors Employee Profile photos with 3rd party system
There are organizations who has a central photo repository which manages employee profile photos and then integrates with all other applications/system who need photos. So if there is a requirement to send the photos to a target system, the OData API “photo”, can be used to retrieve the photos.
Before Jumping directly into the technical details of API, let me first explain few basic details around how photos are stored( formats, size etc.) in Successfactors.
How photos are stored
As soon as employee uploads a photo in employee profile, the system stores several images for the profile picture in different sizes to be used in different applications. For example, thumbnail size images are used in the org chart, quick card and faces page, while larger size images are used in the employee profile. The different photo types are categorized by the field “photoType” and exposed by API (in Binary format).
please see below the dimension for each photo and where it used within Successfactors.
How to extract photo using API
Call the “Photo” OData API, for demo purpose I’m using the s/w postman to query data.
This query will fetch all the 8 different dimension photos.
P.S – In the below output JSON code, i’ve shown only 3 types. Also note, I’ve mentioned “BINARY CODE” for the field “photo” which will contain the actual base64 encoded binary code of the photo.
{
"d": {
"results": [
{
"__metadata": {
"uri": "https://api2preview.sapsf.eu/odata/v2/Photo(photoType=1,userId='4XXXXXX2')",
"type": "SFOData.Photo"
},
"photoType": 1,
"userId": "4XXXXXX2",
"height": 240,
"lastModified": "/Date(1505826327000)/",
"photoId": "13513",
"width": 180,
"photoName": null,
"lastModifiedDateTime": "/Date(1505819127000+0000)/",
"photo": "BINARY CODE",
"mimeType": "image/jpeg",
"lastModifiedWithTZ": "/Date(1505819127000+0000)/",
"userNav": {
"__deferred": {
"uri": "https://api2preview.sapsf.eu/odata/v2/Photo(photoType=1,userId='4XXXXXX2')/userNav"
}
}
},
{
"__metadata": {
"uri": "https://api2preview.sapsf.eu/odata/v2/Photo(photoType=20,userId='4XXXXXX2')",
"type": "SFOData.Photo"
},
"photoType": 20,
"userId": "4XXXXXX2",
"height": 450,
"lastModified": "/Date(1505826193000)/",
"photoId": "13512",
"width": 493,
"photoName": null,
"lastModifiedDateTime": "/Date(1505818993000+0000)/",
"photo": "BINARY CODE",
"mimeType": "image/png",
"lastModifiedWithTZ": "/Date(1505818993000+0000)/",
"userNav": {
"__deferred": {
"uri": "https://api2preview.sapsf.eu/odata/v2/Photo(photoType=20,userId='4XXXXXX2')/userNav"
}
}
},
{
"__metadata": {
"uri": "https://api2preview.sapsf.eu/odata/v2/Photo(photoType=28,userId='4XXXXXX2')",
"type": "SFOData.Photo"
},
"photoType": 28,
"userId": "4XXXXXX2",
"height": 580,
"lastModified": "/Date(1485971949000)/",
"photoId": "1463",
"width": 980,
"photoName": null,
"lastModifiedDateTime": null,
"photo": "BINARY CODE",
"mimeType": "image/jpeg",
"lastModifiedWithTZ": "/Date(1485968349000+0000)/",
"userNav": {
"__deferred": {
"uri": "https://api2preview.sapsf.eu/odata/v2/Photo(photoType=28,userId='4XXXXXX2')/userNav"
}
}
}
]
}
}
Downstream system receiving the photos will have to decode the photos.
For test purpose one can use online base64 encode/decode tool
Generally it’s just the “original” photo which is required, so an additional filter on photoType can be added to extract the required type.
Extracting the photos in delta/incremental mode is the recommended approach. Getting the data in Full mode is not at all suggested because of the photo size.
As of date, the API has a limitation, it cannot identify a deleted photo. When a photo is deleted the query returns PhotoType = 26, 27, 33, however the “last_modified_date” field is not updated and hence it is now possible to identify the “deleted” photos. ( I’ve raised an ER – hopefully SAP will fix it soon)
Check here for SAP reference document on Photo API
Hi Das,
did you get any reply from SAP about limitation that API has whenever photo is deleted?
Thanks in advance.
Luca
Hi Lucas,
Sorry for the delay in response. I have changed project and thus not sure what happened to the Enhancement Request.
Regards
Biplab Das
Hi Das,
Could you please respond to the question raised by Luca, because I am dealing with the same issue.
Kind Regards,
Joris
Hi Joris,
Sorry for the delay in response. I have changed project and thus not sure what happened to the Enhancement Request.
Regards
Biplab Das