openui5
openui5 copied to clipboard
Specific $metadata URL
Loading the SuccessFactors /odata/v2/$metadata takes between 15 and 30 seconds to load (7.5MB). Yes, seconds...
https://launchpad.support.sap.com/#/notes/2755175 specifies the options available to query the $metadata.
Limiting the $metadata to the entities that are used in the UI5 app can greatly improve the performance of the app.
Unfortunately, UI5 supports specifying specific URL query parameters, but as you can see in the KBA, SF only supports specific URL paths.
E.g. having a UI5 app that uses data from User, FormHeader and Photo entities, the $metadata URL would become: /odata/v2/User,Photo,FormHeader/$metadata
It is currently not possible with UI5 to configure this type of $metadata URL.
Hello @piejanssens , Thank you for sharing this finding. I've created an internal incident 2280047446. The status of the issue will be updated here in GitHub. Regards, Diana
Hello @piejanssens,
can you be more specific on what exactly is the issue so that it is not possible with UI5 to configure this type of $metadata URL? As per my investigation there are UI5 apps which successfully use this approach...
Regards, Patric
The issue is that it's not possible to configure a $metadata URL. You can only configure specific $metadata URL parameters.
The OData base URI is /odata/v2, not /odata/v2/User,Photo,FormHeader/, so we cannot set the latter as the URI for the OData service...
This is my unsupported workaround that I implemented to cope with this, but I would prefer having a supported solution through a data source setting that can be configured in the manifest:
sap.ui.define(['sap/ui/model/odata/v2/ODataModel'], function (ODataModel) {
'use strict'
return ODataModel.extend('zspace.ODataModel', {
_createMetadataUrl: function (sUrl) {
let sEntities =
'upsert,User,Photo,FormHeader,RoleEntity,FormCustomElement,JobCodeMappingEntity,FormContent,FormPMReviewContentDetail,FormCustomSection,FormCustomElement,FormObjectiveSection,EmpEmployment'
let url = ODataModel.prototype._createMetadataUrl.apply(this, [
`/${sEntities}${sUrl}`,
])
return url
},
})
})
@piejanssens, my understanding is that /odata/v2/User,Photo,FormHeader/ can be thought of as a virtual OData v2 endpoint. So similarly to how you can get the $metadata for the /odata/v2/ endpoint of SAP SuccessFactors via /odata/v2/$metadata, you can also get the $metadata of the virtual /odata/v2/User,Photo,FormHeader/ via /odata/v2/User,Photo,FormHeader/$metadata. With this virtual endpoint, you should be telling UI5 to use /odata/v2/User,Photo,FormHeader/ as the base URI rather than /odata/v2/, and then UI5 should request /odata/v2/User,Photo,FormHeader/$metadata if and when it needs the $metadata. Have you not found this to be the case, or have you not yet tried changing your base URI from /odata/v2/ to /odata/v2/User,Photo,FormHeader/ in UI5?
@stoehr That seems to be working fine! I never thought about trying actual OData calls on that base URL. Thanks!
@stoehr Issues with this 'virtual endpoint':
-
$batch request: does not support a HEAD request: 404
-
In addition, this doesn't seem to work when you navigate to an associated entity/property or if you include a child property/entity in the $select/$expand query.
/odata/v2/Photo,Picklist/Picklist('sysJobCodes')/picklistOptions
{
"error": {
"code": "COE_PROPERTY_NOT_INCLUDED",
"message": {
"lang": "en-US",
"value": "[COE0022]Properties Picklist/picklistOptions are not accessible. Please check the property name in Admin Center > OData API Data Dictionary or entity metadata."
}
}
}
Hello @piejanssens , Thank you for sharing this finding. I've created an internal incident 2270152826. The status of the issue will be updated here in GitHub.
Hi @piejanssens, the last comment you have posted was completely SFSF OData endpoint specific. Please open a SAP support incident. This request can not be handled here.
@stoehr FYI - Incident 755895 / 2022
@flovogt Please reopen. @stoehr Can you follow up internally, please?
Hello Pieter,
The engineering team answered to me that the comma delimited URL like ( /odata/v2/User,Photo/User ) is not supported for SF Odata API.
Let me know if you have further questions or if I can close the case.
Regards
Hi @piejanssens ,
I agree to Florian that the endpoint issue is a SFSF issue. The ticket you opened is the better way to handle your issue.
Best regards Mathias.
@uhlmannm I would agree, but the quote I posted above is the final reply from the incident...
Hi @piejanssens ,
I had contacted [the colleagues] from the ticket and a colleague working on the SFSF OData framework this morning internally. We cannot resolve this from OpenUI5 side. The ticket is currently with SAP. I propose to follow-up in that ticket.
Best regards Mathias.
@stoehr Issues with this 'virtual endpoint':
- $batch request: does not support a HEAD request: 404
- In addition, this doesn't seem to work when you navigate to an associated entity/property or if you include a child property/entity in the $select/$expand query.
/odata/v2/Photo,Picklist/Picklist('sysJobCodes')/picklistOptions{ "error": { "code": "COE_PROPERTY_NOT_INCLUDED", "message": { "lang": "en-US", "value": "[COE0022]Properties Picklist/picklistOptions are not accessible. Please check the property name in Admin Center > OData API Data Dictionary or entity metadata." } } }
In order to make the virtual endpoint work with the expand feature, you have to add the expanded entities to it. In this case the correct URL to make the call would be: odata/v2/PicklistOption,Picklist/Picklist('sysJobCodes')?$expand=picklistOptions
2. In addition, this doesn't seem to work when you navigate to an associated entity/property or if you include a child property/entity in the $select/$expand query.
Hi Pieter, did you try the above query. For me it works in postman. I get the same error as you if i call
/odata/v2/Photo,Picklist/Picklist('sysJobCodes')/picklistOptions
but if i change this to
odata/v2/PicklistOption,Picklist/Picklist('sysJobCodes')?$expand=picklistOptions
by removing Photo and adding PicklistOption it works. if you use the virtual URL it has to include all entities you will use in SAP UI5. Including all navigated ones.
Best regards Gerald
Hi Gerald,
by removing Photo and adding PicklistOption it works. if you use the virtual URL it has to include all entities you will use in SAP UI5. Including all navigated ones.
Thank you so much! I feel a bit stupid to have overlooked this... 😄
I'll update the incident and refer to your solution, but could you perhaps ask the engineers to look into the HEAD request issue on the virtual URL? If this is fixed, it will make $batch work in SAP UI5... It is used to fetch the X-CSRF-Token.
HEAD /odata/v2/Photo,PicklistOption,Pickist/ vs HEAD /odata/v2/
Best regards,
Pieter
Hi Pieter,
security token handling with SFSF services is a bit complicated. To my knowledge, there are no plans to support the HEAD request. Hence for an OData V2 SFSF service, you will at least need to switch off the HEAD request using the model parameter disableHeadRequestForToken.
Unfortunately, that is not all for now. The ODataModel would then send a GET request with the value Fetch for the token header which is, to my knowledge, also rejected by the SFSF server. There are internal discussions how to handle that but I cannot provide a date when an improvement would be available.
For read-only applications, you may for now simply deactivate the token handling using the model parameter tokenHandling.
Best regards Mathias.