cancel
Showing results for 
Search instead for 
Did you mean: 

@sap/cds-odata-v2-adapter-proxy - problem with FunctionImport

simon_roloff2
Participant
0 Kudos

Hey Community,

I'm getting a warning in the @sap/cds-odata-v2-adapter-proxy console, when calling a function import. I'm getting a response, but it is about one minute delayed, which obviously makes the service useless in my app. Here is the console output of the proxy.

(node:29710) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'ID' of undefined

    at Object.keys.forEach.key (/Users/simonroloff/git/kora-suite-cap/proxy/node_modules/@sap/cds-odata-v2-adapter-proxy/lib/index.js:1283:42)

    at Array.forEach (<anonymous>)

    at data.forEach.data (/Users/simonroloff/git/kora-suite-cap/proxy/node_modules/@sap/cds-odata-v2-adapter-proxy/lib/index.js:1282:25)

    at Array.forEach (<anonymous>)

    at convertRequestData (/Users/simonroloff/git/kora-suite-cap/proxy/node_modules/@sap/cds-odata-v2-adapter-proxy/lib/index.js:1281:10)

    at convertRequestData (/Users/simonroloff/git/kora-suite-cap/proxy/node_modules/@sap/cds-odata-v2-adapter-proxy/lib/index.js:1274:14)

    at convertRequestBody (/Users/simonroloff/git/kora-suite-cap/proxy/node_modules/@sap/cds-odata-v2-adapter-proxy/lib/index.js:1265:7)

    at convertProxyRequest (/Users/simonroloff/git/kora-suite-cap/proxy/node_modules/@sap/cds-odata-v2-adapter-proxy/lib/index.js:492:16)

    at ProxyServer.onProxyReq (/Users/simonroloff/git/kora-suite-cap/proxy/node_modules/@sap/cds-odata-v2-adapter-proxy/lib/index.js:262:9)

    at ProxyServer.emit (/Users/simonroloff/git/kora-suite-cap/proxy/node_modules/eventemitter3/index.js:184:35)

(node:29710) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

(node:29710) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

This is my ODATA2 Request (run in Postman)

http://localhost:4004/v2/odata/v4/NAVIGATE_SRV/GetHierarchy?Child='Test123'

And this is my service definition

	@cds.persistence.skip

	entity ChildSet{

		key Id: String;

		Keydate: String;

		Parent: String;

		Kind: String;

		Desc1: String;

		Desc2: String;

		Childrencount: Integer;

		Openplan: String;

		NextSeparator: String;

		WSApplications: String;

		Responsible: String;

		Redlining: String;

		ValidFrom: String;

		ValidTo: String;

	}

		

	@cds.persistence.skip

	function GetHierarchy(Child:String) returns array of ChildSet;

I'm using the latest version of the proxy:

"@sap/cds-odata-v2-adapter-proxy":"^1.4.29"

Thank you very much for helping me!

Simon

Accepted Solutions (1)

Accepted Solutions (1)

OliverKlemenz
Advisor
Advisor
0 Kudos

Hello Simon,

I could reproduce this issue on my side. The problem looks like, that you send a "content-type" header and provide a non-empty request Body JSON with the GET request.

Then it happens, that the body is parsed, but the definition is a function and not an entity, therefore this exception occurs. I make this more robust at this point.

OData v2 Function call, shall contain the parameters only in the URL, like you already did it.

Can you try calling the GET request without "content-type" header, and with empty body?

Then it works for me.


The long delay I cannot explain. How is the OData V4 service backed? Do you use Java or is the OData V4 service running in the same Node.js?

Best regards,

Oliver

simon_roloff2
Participant
0 Kudos

Hello Oliver,

you are right. I accidentally sent a body with the request. Removing it solved the issue.

Thank you very much!!

Simon

simon_roloff2
Participant
0 Kudos

I use a JAVA ODATA V4 Backend.

Answers (0)