<?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: POST / PUT Requests rejected in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/post-put-requests-rejected/qaa-p/12620463#M4733718</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Probably you need stringify (JSON.stringify()) your body request, For example in your case try to send request with following body:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  '{"title":"test"}'&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 16 May 2022 08:52:48 GMT</pubDate>
    <dc:creator>Wojciech_P</dc:creator>
    <dc:date>2022-05-16T08:52:48Z</dc:date>
    <item>
      <title>POST / PUT Requests rejected</title>
      <link>https://community.sap.com/t5/technology-q-a/post-put-requests-rejected/qaq-p/12620462</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
  &lt;P&gt;everytime I send a POST or PUT request to my service, i get an 400 Error response. The stacktrace tells me: "JSON unexpected end of file". This error is thrown by the deserializationfactory class, but the JSON is valid.&lt;/P&gt;
  &lt;P&gt;For debugging purpose, I made a request with {"title" : "test"} in Insomnia, which led to the same Error message.&lt;/P&gt;
  &lt;P&gt;GET requests work fine.&lt;/P&gt;
  &lt;P&gt;Any ideas?&lt;/P&gt;
  &lt;P&gt;Thanks for help!&lt;/P&gt;
  &lt;P&gt;stacktrace:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;[cds] - DeserializationError: Error while deserializing payload
    at BufferedWriter.&amp;lt;anonymous&amp;gt; (/home/user/projects/testproject/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/DeserializerFactory.js:232:18)
    at BufferedWriter.emit (events.js:400:28)
    at BufferedWriter.&amp;lt;anonymous&amp;gt; (/home/user/projects/testproject/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/utils/BufferedWriter.js:32:12)&amp;lt;br&amp;gt;    at BufferedWriter.emit (events.js:412:35)
    at finish (internal/streams/writable.js:657:10)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  _rootCause: DeserializationError: An error occurred during deserialization of the entity.
      at ResourceJsonDeserializer.deserializeEntity (/home/user/projects/testproject/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/ResourceJsonDeserializer.js:54:13)&amp;lt;br&amp;gt;      at /home/user/projects/cobuy/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/DeserializerFactory.js:44:37
      at BufferedWriter.&amp;lt;anonymous&amp;gt; (/home/user/projects/testproject/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/DeserializerFactory.js:213:28)&amp;lt;br&amp;gt;      at BufferedWriter.emit (events.js:400:28)
      at BufferedWriter.&amp;lt;anonymous&amp;gt; (/home/user/projects/testproject/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/utils/BufferedWriter.js:32:12)&amp;lt;br&amp;gt;      at BufferedWriter.emit (events.js:412:35)
      at finish (internal/streams/writable.js:657:10)
      at processTicksAndRejections (internal/process/task_queues.js:82:21) {
    _rootCause: SyntaxError: Unexpected end of JSON input
        at JSON.parse (&amp;lt;anonymous&amp;gt;)
        at ResourceJsonDeserializer.deserializeEntity (/home/user/projects/testproject/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/ResourceJsonDeserializer.js:48:19)&amp;lt;br&amp;gt;        at /home/user/projects/testproject/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/DeserializerFactory.js:44:37&amp;lt;br&amp;gt;        at BufferedWriter.&amp;lt;anonymous&amp;gt; (/home/user/projects/testproject/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/deserializer/DeserializerFactory.js:213:28)&amp;lt;br&amp;gt;        at BufferedWriter.emit (events.js:400:28)
        at BufferedWriter.&amp;lt;anonymous&amp;gt; (/home/user/projects/testproject/node_modules/@sap/cds/libx/_runtime/cds-services/adapter/odata-v4/okra/odata-server/utils/BufferedWriter.js:32:12)&amp;lt;br&amp;gt;        at BufferedWriter.emit (events.js:412:35)
        at finish (internal/streams/writable.js:657:10)
        at processTicksAndRejections (internal/process/task_queues.js:82:21) {
      _data: undefined
    }
  },
  id: '1899791',
  level: 'WARNING',
  timestamp: 1652689802446
}&amp;lt;br&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;module versions:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;@sap/cds: 5.9.5
@sap/cds-compiler: 2.13.8
@sap/cds-dk: 4.8.2
@sap/cds-dk (global): 4.9.1
@sap/cds-foss: 3.1.1
@sap/cds-mtx: -- missing --
@sap/cds-odata-v2-adapter-proxy: 1.8.16
@sap/eslint-plugin-cds: 2.3.5
@sap/ux-ui5-tooling: 1.5.5
@sap/xssec: 3.2.13
Node.js: v14.17.6&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 May 2022 08:35:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/post-put-requests-rejected/qaq-p/12620462</guid>
      <dc:creator>former_member918821</dc:creator>
      <dc:date>2022-05-16T08:35:14Z</dc:date>
    </item>
    <item>
      <title>Re: POST / PUT Requests rejected</title>
      <link>https://community.sap.com/t5/technology-q-a/post-put-requests-rejected/qaa-p/12620463#M4733718</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Probably you need stringify (JSON.stringify()) your body request, For example in your case try to send request with following body:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  '{"title":"test"}'&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 May 2022 08:52:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/post-put-requests-rejected/qaa-p/12620463#M4733718</guid>
      <dc:creator>Wojciech_P</dc:creator>
      <dc:date>2022-05-16T08:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: POST / PUT Requests rejected</title>
      <link>https://community.sap.com/t5/technology-q-a/post-put-requests-rejected/qaa-p/12620464#M4733719</link>
      <description>&lt;P&gt;The Application already stringifies the body before sending. &lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2022 09:31:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/post-put-requests-rejected/qaa-p/12620464#M4733719</guid>
      <dc:creator>former_member918821</dc:creator>
      <dc:date>2022-05-16T09:31:10Z</dc:date>
    </item>
  </channel>
</rss>

