Symptom
How to add attachment to Background_XXX attachment type field via SF Odata API
Image/data in this KBA is from SAP internal systems, sample data, or demo systems. Any resemblance to real data is purely coincidental.
Environment
- SAP SuccessFactors HCM Suite
- Background entity
Cause
We cannot add attachmetId to navigation section, e.g.
"AttachmentAwardNav": {
"__metadata": {
"uri": "Attachment(9024L)"
}
Resolution
Please help to follow below steps to add attachmentId to Background_XXX entity:
#1. Please create a new attachment and generate to an attachmentId.
POST: {{URLTest}}upsert?$format=json
Payload:
{
"__metadata": {
"uri": "Attachment"
},
"fileName": "111.txt",
"module": "EMPLOYEE_PROFILE",
"externalId": "108743",
"viewable": true,
"fileContent": "VGVzdFRlc3Q"
}
Response:
{
"d": [
{
"key": "Attachment/attachmentId=9122",
"status": "OK",
"editStatus": "UPSERTED",
"message": "Upserted successfully",
"index": 0,
"httpCode": 200,
"inlineResults": null
}
]
}
2. Add this attachmentId to the background attachment type field directly.
POST: {{URLTest}}upsert?$format=json
Payload:
{
"__metadata": {
"uri": "Background_Awards(backgroundElementId=130709L,userId='41000010')",
"type": "SFOData.Background_Awards"
},
"backgroundElementId": "130709",
"name": "Best Manager",
"userId": "41000010",
"AttachmentAward": 9122
}
Response:
{
"d": [
{
"key": "Background_Awards/backgroundElementId=130709,Background_Awards/userId=41000010",
"status": "OK",
"editStatus": null,
"message": null,
"index": 0,
"httpCode": 200,
"inlineResults": null
}
]
}
#3. Get this record to double check this attachment.
Get: {{URLTest}}Background_Awards?$format=json&$expand=AttachmentAwardNav
{
"__metadata": {
"uri": "https://apisalesdemo8.successfactors.com/odata/v2/Background_Awards(backgroundElementId=130709L,userId='41000010')",
"type": "SFOData.Background_Awards"
},
"backgroundElementId": "130709",
"userId": "41000010",
...
},
"AttachmentAwardNav": {
"__metadata": {
"uri": "https://apisalesdemo8.successfactors.com/odata/v2/Attachment(9122L)",
"type": "SFOData.Attachment"
},
"attachmentId": "9122",
"fileName": "111.txt",
"module": "EMPLOYEE_PROFILE",
"externalId": "108743",
"fileContent": "VGVzdFRlc3Q=\r\n",
...
}
--> This attachmentId is added to background attachment field successfully.
Keywords
Background_, attachmentNav, upsert attachment, background attachment, education background, not upsertable , KBA , LOD-SF-INT-ODATA , OData API Framework , LOD-SF-INT-EC , Employee Central SFAPI & OData Entities , Problem
SAP Knowledge Base Article - Public