You are upserting data to a custom MDF object (e.g. cust_ProgressiveDisciplinaryAction) via OData API.
- One of fields in the custom MDF is defined as Type: Attachment (e.g cust_AttachmentNav):
- You receive an error like below when upserting attachment data to the field defined as Type: Attachment
No permission to access the attached file [attachmentName.pdf]. Attachment in field [cust_attachmentField] does not belong to the user [API_USER]. with the index 0
- SAP SuccessFactors HXM Core
- OData API
Reproducing the Issue
Performing an upsert (with user: API_USER) similar to the following results in the error shown in title & symptom section
(i.e. creating a new cust_ProgressiveDisciplinaryAction record for user: ChanA and associating this record with attachmentId=8361 which already exists in the Attachment object)
The error is thrown because userId value stored in Attachment(8361) is not the user: API_USER who is creating the cust_ProgressiveDisciplinaryAction record
The user: API_USER is not authorized to access this attachment because the userId field maintained in this attachment is not "API_USER"
The user who is creating the custom MDF record must be the same user who is maintained in the userId field of the Attachment object/entity.
- To verify what userId is maintained for a given Attachment record, the following OData API request can be used:
https://apisalesdemo4.successfactors.com/odata/v2/Attachment(8360)?$select=userId (change to your own endpoint & attachmentId accordingly)
Additional Note: As a workaround / alternative for such use-cases (custom MDF with associated Attachments)
- You can also validate the use of OAuth 2.0 Authentication - this would result in the user creating their own custom MDF record
- This could be useful in situations where existing Attachment records that already reference an employee's userId need to be associated to custom MDF object records
OData, API, upsert, Attachment, attachmentId, custom, cust_, MDF, userId, permission, does not belong to, , KBA , LOD-SF-INT-ODATA , OData API Framework , Problem