Calling function import from SAP Cloud SDK returns an empty object
See original GitHub issueDescribe the bug Calling a function import from SAP Cloud SDK returns an empty object, even though the call is successful. You can reproduce the issue by using the following git repository. https://github.com/miyasuta/sdk-function-import-test
To Reproduce Steps to reproduce the behavior:
- Develop a custom odata service which includes a function import.
- In a Cloud SDK app, generate an odata client using below command as explained here.
sap-cloud-sdk generate-odata-client -i service-specification/ -o odata-client/
- Call the function import from the Cloud SDK app.
- When the function import gets called, it falls into then() block, meaning that the call was successful. However, the response object is empty.
Expected behavior Response object should be filled with returned data.
Screenshots
Calling the OData function import directly
Calling function import from Cloud SDK app (delivery data should be returned between {})
Used Versions:
- node version via
node -v
: 12.16.1 - npm version via
npm -v
: 6.14.4 - SAP Cloud SDK version you used as dependency: 1.31.0
Code Examples My controller code is as below.
import { Controller, Get } from '@nestjs/common';
import { functionImports } from 'odata-client/catalog-service';
@Controller('get-delivery')
export class GetDeliveryController {
@Get()
getDeliveryInfo() {
return new Promise((resolve, reject) => {
functionImports.getDeliveryDate({})
.execute({
url: 'http://localhost:4004'
})
.then(res => {
resolve('Function call successful: ' + JSON.stringify(res))
})
.catch(error => {
resolve('Error occurred: ' + JSON.stringify(error))
})
})
}
}
Log file No error has occurred.
Additional context None
Please check the following points
- [X ] Have you provided detailed description about your issue?
- [X ] Have you shared all the necessary information to help the cloud-sdk developer reproduce the issue?
- [ X] Have you provided the expected behaviour?
- [ X] Have you attached some useful screenshots?
- [ X] Have you provided the node/npm/cloud-sdk versions?
- [ X] Have you shared your code snippets as a minial example?
- Have you provided you log file or related error messages?
- [ X] Have you searched for related issues on Stackoverflow or answers.sap.com?
Issue Analytics
- State:
- Created 3 years ago
- Comments:21 (14 by maintainers)
Top Results From Across the Web
SAP Cloud SDK: How to call a function import?
When funcGetDeliveryDate gets called, it falles into then() block, meaning that the call was successful. However, the response object is empty.
Read more >SAPUI5 Function import usage - SAP Community
Hello, My colleague has implemented Function Import which downloads ... read instead of callFunction returned object had only empty fields.
Read more >Module @sap/cloud-sdk-core
Returns an access token that can be used to call the given service. The token is fetched via a client credentials grant with...
Read more >FluentHelperFunction (SAP Cloud SDK - Parent POM 3.3.1 API)
Returns : A list of the objects returned by the function call. Returns an empty list if the function did not return a...
Read more >Module @sap/cloud-sdk-core
Internal representation of all parameters of a function import as a map ... Takes a JSON object returned by any of the calls...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @miyasuta, @gregorwolf, @zfrk,
We implemented the feature in
@sap-cloud-sdk/odata-common: 2.3.0
to support the modification of the response data before deserialization.Take the following response as an example:
Now, you can pass
dataAccessor
function as a parameter toexecute()
to modify the response data before the deserialization:I hope it can help you solve the problem. Please re-open the issue if you have any further questions.
Best regards, Zhongpin Wang
Hi @jjtang1985 ,
I had the same kind of issue as @gregorwolf on prem system.
deserializeComplexType(yourResponse.data.d.GetAttachmentCount, YourComplexType)
This is solved my problem, I got the result as I wanted.
Do you consider applying this to the “execute Function” ?
Regards,
Zafer