I used 'cds import' to import the following edmx, which is the SuccessFactors User entity:
https://api2.successfactors.eu/odata/v2/User/$metadata
Hard copy: sf-user.txt
My service.js implementation:
module.exports = async srv => {
const ext = await cds.connect.to('PLTUserManagement')
srv.on('READ', 'User', req => {
console.log('IN READ')
return ext.tx(req).run(req.query)
})
}
When testing the service I receive an error 500 from CDS and a 400 from the remote service:
http://127.0.0.1:4004/userbrowser/User
<error xmlns="http://docs.oasis-open.org/odata/ns/metadata"> <code>500</code> <message>Request failed with status code 400</message> </error>
I stepped through the execution of the request and found the full URL that is composed by cds based on the generated CSN.
/User?$select=userId,addressLine1,addressLine2,addressLine3,benchStrength,bonusBudgetAmount,bonusTarget,businessPhone,businessSegment,cellPhone,citizenship,city,compensationBonusEligible,compensationEligible,compensationReadOnly,compensationSalaryEligible,compensationSalaryRateType,compensationSalaryRateUnits,compensationStockEligible,competency,country,criticalTalentComments,custom01,custom02,custom03,custom04,custom05,custom06,custom07,custom08,custom09,custom10,custom11,custom12,custom13,custom14,custom15,dateOfBirth,dateOfCurrentPosition,dateOfPosition,defaultFullName,defaultLocale,department,division,email,empId,employeeClass,ethnicity,fax,finalJobCode,finalJobFamily,finalJobRole,firstName,futureLeader,gender,hireDate,homePhone,impactOfLoss,impactOfLossComments,issueComments,jobCode,jobFamily,jobLevel,jobRole,jobTitle,keyPosition,lastModified,lastModifiedDateTime,lastModifiedWithTZ,lastName,lastReviewDate,level,localCurrencyCode,location,lumpsum2Target,lumpsumTarget,married,matrix1Label,matrix2Label,matrixManaged,meritEffectiveDate,meritTarget,mi,minority,nationality,newToPosition,nickname,objective,onboardingId,origHireDate,password,payGrade,performance,potential,promotionAmount,raiseProrating,reasonForLeaving,reloComments,reloLocation,reloWilling,reviewFreq,riskOfLoss,salary,salaryBudgetExtra2Percentage,salaryBudgetExtraPercentage,salaryBudgetFinalSalaryPercentage,salaryBudgetLumpsumPercentage,salaryBudgetMeritPercentage,salaryBudgetPromotionPercentage,salaryBudgetTotalRaisePercentage,salaryLocal,salaryProrating,salutation,sciLastModified,seatingChart,serviceDate,ssn,state,status,stockBudgetOptionAmount,stockBudgetOther1Amount,stockBudgetOther2Amount,stockBudgetOther3Amount,stockBudgetStockAmount,stockBudgetUnitAmount,suffix,sysCostOfSource,sysSource,sysStartingSalary,timeZone,title,totalTeamSize,username,veteranDisabled,veteranMedal,veteranProtected,veteranSeparated,zipCode,customManager_userId,customReports_userId,directReports_userId,hr_userId,hrReports_userId,manager_userId,matrixManager_userId,matrixReports_userId,proxy_userId,secondManager_userId,secondReports_userId,userPermissionsNav_userId&$orderby=userId%20asc&$top=1000
Executing this same path via Postman renders the same error code but provides more information in the error returned:
<?xml version="1.0" encoding="utf-8"?> <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> <code>COE_PROPERTY_NOT_FOUND</code> <message lang="en-US">[COE0021]Invalid property names: User/customManager_userId. Please check the property name in Admin Center > OData API Data Dictionary or entity metadata. Ensure there were no data model changes that removed this field, and please execute a refresh metadata to ensure the cache is not corrupted.</message> </error>
I guess the underlying issue is that the EDMX file from the API business hub is not in line with the current OData implementation of SuccessFactors' API.
What confuses me here is that in my implementation I'm asking to forward the incoming query to the remote service. The query seems to be '/User' and not '/User?$select=...'. Why is CDS doing this and how can I 'fix' it?
I changed the implementation to get the entire entity without the $select:
module.exports = async srv => {
const ext = await cds.connect.to('SF_User')
srv.on('READ', 'User', async req => {
console.log('IN READ')
const result = await ext.tx(req).get('/User')
return result
})
}
And this is then resulting in another error which I don't know how to get around...
<error xmlns="http://docs.oasis-open.org/odata/ns/metadata"> <code>null</code> <message>An error occurred during serialization of the entity collection. An error occurred during serialization of the entity with the following key(s): userId: SFADMIN. The entity contains data for 'delegatorOfAutoDelegateConfigNav' which does not belong to the structural or navigation properties of the type 'User'.</message> </error>