question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Batch request fails with CAP

See original GitHub issue

Describe the bug I am using the “SDK’s Generator for JavaScript” to generate OData client for a service generated by using CAP (following this blog post). After I change the default service path from VALUE_IS_UNDEFINED to my service path (/sitn-admin-srv) I could use all the operations without any problem. However, when I use the batch request (following this blog post), the request has reached to the server fine, but I got warnings in the server side;
[2020-10-19T13:35:50.287Z | WARNING | 1854218]: 'sitn' is not an entity set, a singleton, an action import, or a function import
where my service path is sitn-admin-srv.

When I set the _defaultServicePath to empty string in the entity level (file is SituationTemplateMetaData.ts), then batch request works fine, but of course all the single operations are being made to the root level and I get 404 errors for the single operations.

Maybe the batch request concatenates the default service path twice? Or am I doing something wrong?

To Reproduce Steps to reproduce the behavior:

  1. Get any OData service (like bookshop app)
  2. Generate client library using the generator
  3. Change the default paths in generated files export const defaultSitnAdminSrvServicePath = '/<serice-path>'; in BatchRequest.ts and static _defaultServicePath = '/<service-path>'; in <entity>.ts
  4. Single requests will work, but batch request will get a warning like above.
  5. Leave the service path empty in the entity file, batch request will work but the single requests will get 404.

I can also provide you my code, or collabrate further if there is a need.

Used Versions:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
marikanercommented, Oct 27, 2020

Hey @meakgoz2,

according to the batch specification endpoints that accept batch should allow to set subrequest paths that are absolute, relative to the service or relative to the entity set. The SDK sets the subrequest path relative to the service by default, but CAP currently only accepts paths relative to the entity set. We provide an additional configuration option that you can use to diverge from this default behaviour.

Try:

batch(...).withSubRequestType('relativeToEntity')

I hope that helps, we will add documentation on this soon.

1reaction
marikanercommented, Nov 11, 2020

Hey @meakgoz2, we have added this to our documentation here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SAP CAP - Batch requests not working correctly
I have a sap CAP OData service with V2 Adapter proxy which points to cloud HANA database in SAP Cloud Foundry. And I'm...
Read more >
Best Practices - SAP Capire
From generic Node.js best practices like dependency management and error handling to CAP-specific topics like transaction handling and testing, ...
Read more >
Use the OData v2 Type-safe Client API | SAP Cloud SDK
Use SAP Cloud SDK for Java to build and run OData v2 requests in a type-safe way. ... Use executeRequest to issue the...
Read more >
sap/cds-odata-v2-adapter-proxy (cov2ap) - npm
const cds = require("@sap/cds"); const cov2ap ... Response processing error; [cov2ap] - Batch: Batch processing error ... CAP Node.js Custom.
Read more >
Batch Processing (OData Version 2.0)
An OData Batch Request is represented as a Multipart MIME v1.0 message ... applied before another request in that same ChangeSet failed and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found