on 11-29-2020 10:47 PM
Hi experts!!
I'm trying to save several entries in my external service, but it isn't work.
When i execute INSERT sentence for one register it works and it's saved in the database:
await tx.run((INSERT.into(location_sync, [{Werks: 'tes2', Stand:'test', Ktext: 'test'}])));
But when i try to do the same for a table of objects, the error is the same, returns 400 status Bad request: error while deserializing payload.
I have revised whole the fields and it seems it's all okay.
This is the csn imported from external service:
"kind": "entity",
"@cds.persistence.skip": true,
"elements": {
"Werks": {
"key": true,
"type": "cds.String",
"length": 4
},
"Stand": {
"key": true,
"type": "cds.String",
"length": 10
},
"Ktext": {
"type": "cds.String",
"length": 40
}
}
And this is the cds in the original service:
entity location_sync {
key Werks : String(4);
key Stand : String(10);
Ktext : String(40);
}
Do you have some idea?
Thanks in advance!
Best regards
Do you know if your external service allows $batch requests? Since, INSERT with multiple rows is using in the background a batch request.
However, you could try to make a foreach on your array and each entry shall be a single insert into. Be aware here about creating multiple Promises and resolve them all at once to avoid a waiting period since you otherwise do an await for each entry.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please try with:
INSERT.into(location_sync).rows(arrayWithLocationSyncData)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.