on 07-08-2020 1:12 PM
Hello!
I´m facing a problem while trying to build a List Report front end on top of a CAP service which I enabled for CRUD operations. I´m assuming that @odata.draft.enabled enables the entity for CRUD, so my service is like this (simplest service I can figure out):
schema.cds:
namespace p4;
entity Ent1 {
key id: Integer;
description: String(100);
}
cat-service.cds:
using { p4 as my } from '../db/schema';
@path:'/catalog'
service CatalogService {
@odata.draft.enabled
entity Ent1 as projection on my.Ent1;
}
As I run it locally and launch the "preview in Fiori" I have all the buttons for CRUD. I can update and delete entries. But as I try to create an entry that´s what happens:
This is the data from the 'Headers' section:
Request URL:
http://localhost:4004/catalog/$batch
Referrer Policy:
no-referrer-when-downgrade
Request HeadersAccept:
multipart/mixed
Accept-Encoding:
gzip, deflate, br
Accept-Language:
pt-BR
Connection:
keep-alive
Content-Length:
330
Content-Type:
multipart/mixed; boundary=batch_id-1594208238132-51
Host:
localhost:4004
MIME-Version:
1.0
OData-MaxVersion:
4.0
OData-Version:
4.0
Origin:
http://localhost:4004
Referer:
http://localhost:4004/$fiori-preview/?service=CatalogService&entity=Ent1
Sec-Fetch-Dest:
empty
Sec-Fetch-Mode:
cors
Sec-Fetch-Site:
same-origin
User-Agent:
Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
X-CSRF-Token:
null
X-Requested-With:
XMLHttpRequest
Request Payload--batch_id-1594208238132-51
Content-Type:application/http
Content-Transfer-Encoding:binaryPOST Ent1 HTTP/1.1
Accept:application/json;odata.metadata=minimal;IEEE754Compatible=true
Accept-Language:pt-BR
X-CSRF-Token:
Content-Type:application/json;charset=UTF-8;IEEE754Compatible=true
{}
--batch_id-1594208238132-51--
This $batch request is kind of confusing to me, but it looks like the List Report is sending the POST with no data inside the curly-brackets and this is being rejected by the CAP service. It looks odd to me. On the console we got this:
POST /catalog/$batch
> NEW Ent1 null
[2020-07-08T11:37:18.170Z | ERROR | 1788582]: Cannot convert undefined or null to object
[2020-07-08T11:37:18.170Z | ERROR | 1788582]: Error stacktrace: TypeError: Cannot convert undefined or null to object
at removeDraftUUID (C:\Dev\Estudo\Cds\ws1\p4\node_modules\@sap\cds-runtime\lib\cds-services\services\utils\draftUtils.js:224:5) at C:\Dev\Estudo\Cds\ws1\p4\node_modules\@sap\cds-runtime\lib\cds-services\services\handlers\onCreateDraft.js:96:14
[INTERNAL ERROR] TypeError: Cannot convert undefined or null to object
at removeDraftUUID (C:\Dev\Estudo\Cds\ws1\p4\node_modules\@sap\cds-runtime\lib\cds-services\services\utils\draftUtils.js:224:5)
at C:\Dev\Estudo\Cds\ws1\p4\node_modules\@sap\cds-runtime\lib\cds-services\services\handlers\onCreateDraft.js:96:14
Please report this error.
I have also tried to deploy (similar service, the real one) to CF and use Fiori-Tools to have a "real" app running over the V2 (server.js approach) , but for this one I get a different error in the same point:
502 Bad Gateway: Registered endpoint failed to handle the request.
I figured out that in this case the failing request is like this:
###
POST http://localhost:8080/v2/adm/Ingredientes
Content-Type: application/json
{"__metadata":{"type":"AdmService.Ingredientes"}}
and the response is like this:
HTTP/1.1 502 Bad Gateway
x-powered-by: Express
content-type: text/plain; charset=utf-8
x-cf-routererror: endpoint_failure
x-content-type-options: nosniff
date: Wed, 08 Jul 2020 12:01:38 GMT
Content-Length: 67
connection: close
strict-transport-security: max-age=31536000; includeSubDomains; preload;
Vary: Accept-Encoding
502 Bad Gateway: Registered endpoint failed to handle the request.
This is kind of similar with this other question:
But in my case I´m not getting the SAML2 message, and I´m don´t have the SAML2 parameter in my manifest.json (generated by the fiori tools).
I have also tried to generate the List Report with the WebIDE wizard. This one generates the SAML2 paramters but I removed it and the results are the same.
Well, I have been writen a lot here... To sumarize it, all I want to do is to put up together a functional List Report CRUD over a simple CAP service. I´m trying it with that @odata.draft.enabled annotation but with no success, be it local preview (odata v4) or app on cloud (odata v2). If someone could please put some light on it to me I would thank you very much!
Thanks! Eric
I had same issue but you can do this by changing key id : UUID; then you can do create operation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.