cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CAPM - Uncaught TypeError: target.keys is not iterable

0 Likes
596

I'm studying CAP and I'm getting an error when calling the POST Method.

[cds] - ️Uncaught TypeError: target.keys is not iterable in calculateLocationHeader (/home/user/projects/first-project/node_modules/@sap/cds/libx/odata/utils/index.js:284:35) in /home/user/projects/first-project/node_modules/@sap/cds/libx/odata/middleware/create.js:76:31 in process.processTicksAndRejections (node:internal/process/task_queues:95:5)

 

My Entity

entity Customers {
    name    : String(100);
    age     : Integer;
}
 
Definy my service
service Main {
    entity Customers as projection on db.Customers;
}
 
Call de POST method
@auth = Authorization: Basic alice:


### Customers
# @name Customers_GET
GET {{server}}/odata/v4/main/Customers
{{auth}}

### Customers
# @name Customers_POST
POST {{server}}/odata/v4/main/Customers
Content-Type: application/json
{{auth}}

{
  "name": "name-4332508",
  "age": 39
}

Error
GeovaneAlborghetti_2-1738005279681.png

 

Has anyone ever caught this error?

 

 

 

Accepted Solutions (1)

Accepted Solutions (1)

Dinu
Active Contributor

add a key to your entity. The easiest would be to use the aspect cuid. 

using {cuid} from '@sap/cds/common';
entity Customers: cuid {
    name    : String(100);
    age     : Integer;
}

 

0 Likes

Hi Dinu,

It worked, thanks for help me.

Answers (0)