2025 Mar 25 8:18 AM - edited 2025 Mar 25 8:31 AM
Hello,
I have an oData v2 backend service service1 published by an BTP destination destination1. To consume this external service I imported the service1.xml metadata file using cds import. Next I run the application and call the local host. As far as good and Entities are shown as Service Endpoints.
But when I select one, it shows for example for entity1 (v4):
{"@odata.context":"$metadata#entity1","value":[]}and for entity1 (v2):
{"d":{"results":[]}}And that happens, even if the odata v2 service has data! URL via browser gives me full results.
I tried creating service.cds and service.js files, but it also shows empty data.
const cds = require('@sap/cds');
module.exports = cds.service.impl(async function() {
const { entity1 } = this.entities; const srv = await
cds.connect.to("service1") // Handle READ operations
this.on('READ', entity1, async (req) => {
const result = await srv.run(SELECT.from('entity1'));
console.log(`Retrieved ${result.length} entries from external service`);
});
}); I implemented the backend in my package.json like this:
"cds": {
"requires": {
"service1": {
"kind": "odata-v2",
"model": "srv/external/service1"
}
}
}Thank you in advance!
For completion also the results from the backend:
https://destination1.xxxx.de/sap/opu/odata/service1/$metadata
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:sap="http://www.sap.com/Protocols/SAPData" Version="1.0">
<edmx:DataServices m:DataServiceVersion="2.0">
<Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm" Namespace="service1" xml:lang="en" sap:schema-version="1">
<EntityType Name="entity1" sap:content-version="1">
<Key>
<PropertyRef Name="id"/>
</Key>
<Property Name="id" Type="Edm.String" Nullable="false" sap:unicode="false" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="appl" Type="Edm.String" Nullable="false" sap:unicode="false" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="props" Type="Edm.String" Nullable="false" sap:unicode="false" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="actions" Type="Edm.String" Nullable="false" sap:unicode="false" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="requestdata" Type="Edm.String" Nullable="false" sap:unicode="false" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="attachments" Type="Edm.String" Nullable="false" sap:unicode="false" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
</EntityType>and the https://destination1.xxxxx.de/sap/opu/odata/service1/entity1
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="https://destination1.xxxxxx.DE:443/sap/opu/odata/service1/">
<id>https://destination1.xxxxxx.DE:443/sap/opu/odata/service1/entity1</id>
<title type="text">entity1</title>
<updated>2025-03-25T08:27:27Z</updated>
<author>
<name/>
</author>
<link href="entity1" rel="self" title="entity1"/>
<entry>
<id>https://destination1.xxxxxx.DE:443/sap/opu/odata/service1/entity1('DUMMY%3A1')</id>
<title type="text">entity1('DUMMY%3A1')</title>
<updated>2025-03-25T08:27:27Z</updated>
<category term="service1.entity1" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link href="entity1('DUMMY%3A1')" rel="self" title="entity1"/>
<content type="application/xml">
<m:properties xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
<d:id>DUMMY:1</d:id>
<d:appl/>
<d:props>[{"KEY":"application","VALUE":"DUMMY"}]</d:props>
<d:actions>[{"ACTION":"ActionID1","TEXT":"TextOnButton1","ACTIVE":"X"},{"ACTION":"ActionID2","TEXT":"TextOnButton2","ACTIVE":"X"},{"ACTION":"ActionID3","TEXT":"TextOnButton3","ACTIVE":""}]</d:actions>
<d:requestdata>[{"COLUMN1":"Line1-column1","COLUMN2":"Line1-column2","COLUMN3":"Line1-column3","COLUMN4":"Line1-column4","COLUMN5":"Line1-column5"},{"COLUMN1":"Line2-column1","COLUMN2":"Line2-column2","COLUMN3":"Line2-column3","COLUMN4":"Line2-column4","COLUMN5":"Line2-column5"}]</d:requestdata>
<d:attachments>[{"ID":"attachment1","DESCR":"Attachment 1","MIME_TYPE":"application/pdf","SIZE":156400,"KEY1":"122","KEY2":"10","KEY3":"","KEY4":""},{"ID":"attachment2","DESCR":"Attachment 2","MIME_TYPE":"image/jpeg","SIZE":65789,"KEY1":"123","KEY2":"20","KEY3":"","KEY4":""}]</d:attachments>
</m:properties>
</content>
</entry>
Request clarification before answering.
| User | Count |
|---|---|
| 7 | |
| 7 | |
| 6 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.