on 07-20-2021 10:18 AM
sample: https://github.com/SAP-samples/cloud-cap-samples-java.git
- cds path: cloud-cap-samples-java/srv/review-service.cds
call odata url: https://workspaces-ws-#####-app1.####.trial.applicationstudio.cloud.sap/api/review/Books_texts
return value:
{ "error": { "code": "403001", "message": "Not authorized to send event 'READ' to 'ReviewService.Books.texts'" } }
java stack error:
2021-07-20 17:33:59.428 INFO 1484 --- [nio-8080-exec-5] c.s.c.a.o.v4.processors.CdsProcessor : Exception marked the ChangeSet 16 as cancelled: Not authorized to send event 'READ' to 'ReviewService.Books.texts' (service 'ReviewService', event 'READ', entity 'ReviewService.Books.texts')
The behaviour of CAP Java is the expected one here. The Books_texts entity in the ReviewService in the Java sample is not explicitly exposed by the service. It is implicitly auto-exposed. Implicitly auto-exposed entities are not accessible directly, but only via proper navigation paths. You would need to run one of the following requests to obtain the texts of books:
https://workspaces-ws-#####-app1.####.trial.applicationstudio.cloud.sap/api/review/Books?$expand=tex...
https://workspaces-ws-#####-app1.####.trial.applicationstudio.cloud.sap/api/review/Books(...)/texts
In case you directly want to make the entity available you need to explicitly declare it in the service, for example:
extend service ReviewService with {
@requires: 'any' // or any other appropriate authorization
entity Books.texts as projection on my.Books.texts;
}
See also more information about this in our documentation: https://cap.cloud.sap/docs/guides/authorization#events-and-auto-expose
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Becker,
Thank you for the advice.
I solved it as below through your advice.
annotate Books.texts with @cds.autoexpose; //In Node.js(cds watch)
annotate Books.texts with @(cds.autoexpose,requires:'any'); //In Java(mvn spring-boot:run) //cds.services.version@1.15.3,@sap/cds@5.3.2
//Not Working//annotate Books.texts with @(cds.autoexpose,requires:'any'); //In Java(mvn spring-boot:run) //cds.services.version@1.15.3,@sap/cds@4.6.6
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.