cancel
Showing results for 
Search instead for 
Did you mean: 

CPI Rest endpoint is being hit Multiple times from SAP CAP API

parthasaradhi
Explorer
0 Kudos

Hi Experts,

I am working on a scenario where I need to post some data from my CAP application to a rest endpoint exposed by CPI.

For this I have created a destination in the subaccount and then trying to call the endpoint from my program.

Now when I make a call to CPI endpoint from my CAP application, in the CPI Monitoring section I am able to see that API is being hit for 3 times. But from my application I am making a single call. I have not placed the call in any loop.

But still, I can see that CPI rest endpoint is being hit 3 times. But when I call the endpoint from Postman it is being hit for 1 time.

Can anyone provide some inputs on how to resolve this?

PFB the code I am using in my app to call the CPI rest endpoint.

let CPI_REST_API = await cds.connect.to('my Destination');

let data = {"ID": 1}

let CPI_post = await CPI_REST_API.send('POST', 'Endpointpath', data).

Accepted Solutions (0)

Answers (1)

Answers (1)

martinstenzig
Contributor
0 Kudos

Three options I would check into:

1. Is your code to call CPI in the correct place so that it is not called three times. (I would add some debugging and then check the log outputs with 'cf logs [app name]'

2. I had a problem similar to this that was caused by an error that I didn't see but throwing exceptions on the server side and then 'redoing' the same piece of code. Investigation: 'cf logs [app name]' and see what's happening

3. Do you have multiple instances (maybe 3) of your service running that could explain the multiple calls?