Symptom
How to create an OData API request to upsert photos.
Environment
- SAP SuccessFactors HXM Suite
- OData API
Resolution
1. First, it is necessary to check the authorizations for the API user. In order to upsert the profile photo it is required to have the following:
- Permissions: There is no permission check for query operation. You need to set the following permissions to enable edit operations like Import,Merge,Replace,Upsert and Delete:
- Role-based: Go to Admin Tools > Manage Permission Roles > Permission Settings > Employee Data > Enable Edit Permission for Photo field and click Done.
- User-based: Go to Succession Management > Import/Export Data Model . Export the file and edit it to grant write permission on "Photo" element to the correct roles. Import the revised xml file.
2. Then, determine the appropriate OData endpoint as per KBA 2215682 and add the following suffix:
Example: http://<hostname>/odata/v2/upsert?$format=json
3. Encode photo into a base64-string.
4. Send a POST HTTP method and the HTTP header with the authorization and preferred authentication type.
HTTP Header: Accept: application/json
HTTP Header: Content-Type: application/jsonHTTP Body:
[
{
"__metadata": {
"uri": "Photo(photoType=1,userId='userID')",
"type": "SFOData.Photo"
},
"photoType" : 1,
"userId": "userID",
"photoName" : null,
"photo": "BASE64_ENCODED_STRING"
},
{
"__metadata": {
"uri": "Photo(photoType=1,userId='userID')",
"type": "SFOData.Photo"
},
"photoType" : 1,
"userId": "userID",
"photoName" : null,
"photo": "BASE64_ENCODED_STRING"
}
]
Please follow the example formats attached in the "attachment section"
For Insert Scenario --> Insert_photo.zip
For Upsert Scenario --> Upsert_photo.zip
See Also
The photoType can be changed according SAP SuccessFactors HCM Suite OData API: Reference Guide on Photo Types subsession from 5.10 Photo Chapter.
You can upload the Live profile photo, Background photo, etc. Please verify the handbook to get the right ID and photo requirements.
Keywords
Upsert, photo, OData, API, URL, profile photo upsert, background photo upsert, , KBA , LOD-SF-INT-ODATA , OData API Framework , LOD-SF-INT , Integrations , How To
Product
Attachments
Upsert_photo.zip |
Insert_Photo.zip |