<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Error when creating several entries CAP in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/error-when-creating-several-entries-cap/qaa-p/12236061#M4580966</link>
    <description>&lt;P&gt;Do you know if your external service allows $batch requests? Since, INSERT with multiple rows is using in the background a batch request.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;</description>
    <pubDate>Thu, 03 Dec 2020 08:15:34 GMT</pubDate>
    <dc:creator>leoirudayam</dc:creator>
    <dc:date>2020-12-03T08:15:34Z</dc:date>
    <item>
      <title>Error when creating several entries CAP</title>
      <link>https://community.sap.com/t5/technology-q-a/error-when-creating-several-entries-cap/qaq-p/12236058</link>
      <description>&lt;P&gt;Hi experts!!&lt;/P&gt;
  &lt;P&gt;I'm trying to save several entries in my external service, but it isn't work.&lt;/P&gt;
  &lt;P&gt;When i execute INSERT sentence for one register it works and it's saved in the database:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;await tx.run((INSERT.into(location_sync, [{Werks: 'tes2', Stand:'test', Ktext: 'test'}])));
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1865777-3qeqi.png" /&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG alt="" style="font-size: 15px; color: rgb(60, 60, 60);" /&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1865783-2020-11-29-23-37-46-sap-business-application-studi.png" /&gt;&lt;/P&gt;
  &lt;P&gt;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.&lt;/P&gt;
  &lt;P&gt;I have revised whole the fields and it seems it's all okay.&lt;/P&gt;
  &lt;P&gt;This is the csn imported from external service:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;      "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
        }
      }

&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;And this is the cds in the original service:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;entity location_sync {
    key Werks : String(4);
    key Stand : String(10);
        Ktext : String(40);
}

&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Do you have some idea?&lt;/P&gt;
  &lt;P&gt;Thanks in advance!&lt;/P&gt;
  &lt;P&gt;Best regards&lt;/P&gt;</description>
      <pubDate>Sun, 29 Nov 2020 22:47:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/error-when-creating-several-entries-cap/qaq-p/12236058</guid>
      <dc:creator>smorenod</dc:creator>
      <dc:date>2020-11-29T22:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: Error when creating several entries CAP</title>
      <link>https://community.sap.com/t5/technology-q-a/error-when-creating-several-entries-cap/qaa-p/12236059#M4580964</link>
      <description>&lt;P&gt;Please try with:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;INSERT.into(location_sync).rows(arrayWithLocationSyncData)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Nov 2020 06:33:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/error-when-creating-several-entries-cap/qaa-p/12236059#M4580964</guid>
      <dc:creator>gregorw</dc:creator>
      <dc:date>2020-11-30T06:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: Error when creating several entries CAP</title>
      <link>https://community.sap.com/t5/technology-q-a/error-when-creating-several-entries-cap/qaa-p/12236060#M4580965</link>
      <description>&lt;P&gt;thanks Gregor, yeah i tried with that too and fails, I think the problem is that the service is an extarnal service, and what it's trying to do is a POST with multiples entities and it's not support.&lt;/P&gt;&lt;P&gt;There is some option to execute the insert inside a loop?&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 08:41:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/error-when-creating-several-entries-cap/qaa-p/12236060#M4580965</guid>
      <dc:creator>smorenod</dc:creator>
      <dc:date>2020-11-30T08:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: Error when creating several entries CAP</title>
      <link>https://community.sap.com/t5/technology-q-a/error-when-creating-several-entries-cap/qaa-p/12236061#M4580966</link>
      <description>&lt;P&gt;Do you know if your external service allows $batch requests? Since, INSERT with multiple rows is using in the background a batch request.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Dec 2020 08:15:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/error-when-creating-several-entries-cap/qaa-p/12236061#M4580966</guid>
      <dc:creator>leoirudayam</dc:creator>
      <dc:date>2020-12-03T08:15:34Z</dc:date>
    </item>
  </channel>
</rss>

