<?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>topic CL_HTTP_CLIENT-&amp;gt;request-&amp;gt;set_data failed 400 if data &amp;gt;= 1024 bytes in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/cl-http-client-gt-request-gt-set-data-failed-400-if-data-gt-1024-bytes/m-p/12774814#M2023279</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
  &lt;P&gt;I`m using a POST request with a JSON throught CL_HTTP_CLIENT.&lt;/P&gt;
  &lt;P&gt;Faced the following situation:&lt;/P&gt;
  &lt;P&gt;When xstrlen( jsonx ) &amp;lt;= 1024 &lt;/P&gt;
  &lt;P&gt; &lt;STRONG&gt; http_rc = 200. "OK"&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;When xstrlen( jsonx ) &amp;gt; 1024&lt;/P&gt;
  &lt;P&gt; &lt;STRONG&gt; http_rc = 400. "Incorrect data given"&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;Tried to send the same data not via SAP client - Result &lt;STRONG&gt;200. "OK"&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;Instead of client-&amp;gt;request-&amp;gt;set_data I used client-&amp;gt;request-&amp;gt;set_сdata, the result is similar, as soon as the string size exceeds 1024 bytes, I get a &lt;STRONG&gt;400&lt;/STRONG&gt; response.&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;icm/HTTP/max_request_size_KB - 102400&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;What could be the error, am I somehow filling in the data incorrectly?&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;Where can there be size limits for request data?&lt;/STRONG&gt;&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;DATA: client TYPE REF TO if_http_client.

  cl_http_client=&amp;gt;create_by_destination( EXPORTING
     destination = 'z_test'
     IMPORTING
       client = client ).

  client-&amp;gt;propertytype_logon_popup = if_http_client=&amp;gt;co_disabled.
  client-&amp;gt;request-&amp;gt;set_version( if_http_request=&amp;gt;co_protocol_version_1_1 ).
  client-&amp;gt;request-&amp;gt;set_method( if_http_request=&amp;gt;co_request_method_post ).
  client-&amp;gt;request-&amp;gt;set_header_field( name = 'Accept'        value = 'application/json' ).
  client-&amp;gt;request-&amp;gt;set_header_field( name = 'Content-Type'  value = 'application/json' ).
  client-&amp;gt;request-&amp;gt;set_header_field( name = 'Authorization' value = |Bearer TokenValue| ).

  DATA jsonx TYPE xstring.

  json = '{"someLongJSON....}'.
  
  jsonx = cl_abap_codepage=&amp;gt;convert_to(
           source = json
           codepage = 'UTF-8' ).

  DATA(json_lenx) = xstrlen( jsonx ).
  client-&amp;gt;request-&amp;gt;set_data( data = jsonx
                             offset = 0
                             length = json_lenx ).

*  DATA(get_jsonx) = client-&amp;gt;request-&amp;gt;get_cdata( ).

  CALL METHOD client-&amp;gt;send
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2
      http_processing_failed     = 3
      http_invalid_timeout       = 4
      OTHERS                     = 5.
  IF sy-subrc &amp;lt;&amp;gt; 0.
    RAISE connection_error.
  ENDIF.
  CALL METHOD client-&amp;gt;receive
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2
      http_processing_failed     = 3
      OTHERS                     = 4.
  IF sy-subrc = 0.
    DATA: http_rc TYPE sy-subrc.
    client-&amp;gt;response-&amp;gt;get_status( IMPORTING code = http_rc ).
    l_xml = client-&amp;gt;response-&amp;gt;get_cdata( ).
  ENDIF.
  client-&amp;gt;close( ).&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 28 Aug 2023 16:30:00 GMT</pubDate>
    <dc:creator>former_member875618</dc:creator>
    <dc:date>2023-08-28T16:30:00Z</dc:date>
    <item>
      <title>CL_HTTP_CLIENT-&gt;request-&gt;set_data failed 400 if data &gt;= 1024 bytes</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cl-http-client-gt-request-gt-set-data-failed-400-if-data-gt-1024-bytes/m-p/12774814#M2023279</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
  &lt;P&gt;I`m using a POST request with a JSON throught CL_HTTP_CLIENT.&lt;/P&gt;
  &lt;P&gt;Faced the following situation:&lt;/P&gt;
  &lt;P&gt;When xstrlen( jsonx ) &amp;lt;= 1024 &lt;/P&gt;
  &lt;P&gt; &lt;STRONG&gt; http_rc = 200. "OK"&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;When xstrlen( jsonx ) &amp;gt; 1024&lt;/P&gt;
  &lt;P&gt; &lt;STRONG&gt; http_rc = 400. "Incorrect data given"&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;Tried to send the same data not via SAP client - Result &lt;STRONG&gt;200. "OK"&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;Instead of client-&amp;gt;request-&amp;gt;set_data I used client-&amp;gt;request-&amp;gt;set_сdata, the result is similar, as soon as the string size exceeds 1024 bytes, I get a &lt;STRONG&gt;400&lt;/STRONG&gt; response.&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;icm/HTTP/max_request_size_KB - 102400&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;What could be the error, am I somehow filling in the data incorrectly?&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;Where can there be size limits for request data?&lt;/STRONG&gt;&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;DATA: client TYPE REF TO if_http_client.

  cl_http_client=&amp;gt;create_by_destination( EXPORTING
     destination = 'z_test'
     IMPORTING
       client = client ).

  client-&amp;gt;propertytype_logon_popup = if_http_client=&amp;gt;co_disabled.
  client-&amp;gt;request-&amp;gt;set_version( if_http_request=&amp;gt;co_protocol_version_1_1 ).
  client-&amp;gt;request-&amp;gt;set_method( if_http_request=&amp;gt;co_request_method_post ).
  client-&amp;gt;request-&amp;gt;set_header_field( name = 'Accept'        value = 'application/json' ).
  client-&amp;gt;request-&amp;gt;set_header_field( name = 'Content-Type'  value = 'application/json' ).
  client-&amp;gt;request-&amp;gt;set_header_field( name = 'Authorization' value = |Bearer TokenValue| ).

  DATA jsonx TYPE xstring.

  json = '{"someLongJSON....}'.
  
  jsonx = cl_abap_codepage=&amp;gt;convert_to(
           source = json
           codepage = 'UTF-8' ).

  DATA(json_lenx) = xstrlen( jsonx ).
  client-&amp;gt;request-&amp;gt;set_data( data = jsonx
                             offset = 0
                             length = json_lenx ).

*  DATA(get_jsonx) = client-&amp;gt;request-&amp;gt;get_cdata( ).

  CALL METHOD client-&amp;gt;send
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2
      http_processing_failed     = 3
      http_invalid_timeout       = 4
      OTHERS                     = 5.
  IF sy-subrc &amp;lt;&amp;gt; 0.
    RAISE connection_error.
  ENDIF.
  CALL METHOD client-&amp;gt;receive
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2
      http_processing_failed     = 3
      OTHERS                     = 4.
  IF sy-subrc = 0.
    DATA: http_rc TYPE sy-subrc.
    client-&amp;gt;response-&amp;gt;get_status( IMPORTING code = http_rc ).
    l_xml = client-&amp;gt;response-&amp;gt;get_cdata( ).
  ENDIF.
  client-&amp;gt;close( ).&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Aug 2023 16:30:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cl-http-client-gt-request-gt-set-data-failed-400-if-data-gt-1024-bytes/m-p/12774814#M2023279</guid>
      <dc:creator>former_member875618</dc:creator>
      <dc:date>2023-08-28T16:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: CL_HTTP_CLIENT-&gt;request-&gt;set_data failed 400 if data &gt;= 1024 bytes</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cl-http-client-gt-request-gt-set-data-failed-400-if-data-gt-1024-bytes/m-p/12774815#M2023280</link>
      <description>&lt;P&gt;Hello Anton,&lt;/P&gt;&lt;P&gt;Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with &lt;A href="https://community.sap.com/resources/questions-and-answers" target="test_blank"&gt;https://community.sap.com/resources/questions-and-answers&lt;/A&gt;, as it provides tips for preparing questions that draw responses from our members.&lt;/P&gt;&lt;P&gt;Feel free to take our Q&amp;amp;A tutorial at &lt;A href="https://developers.sap.com/tutorials/community-qa.html" target="test_blank"&gt;https://developers.sap.com/tutorials/community-qa.html&lt;/A&gt; as well, as that will also help you when preparing questions for the community.&lt;/P&gt;&lt;P&gt;By adding a picture to your profile you encourage your readers to respond.&lt;/P&gt;&lt;P&gt;Kind regards,&lt;BR /&gt;Anne&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2023 16:30:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cl-http-client-gt-request-gt-set-data-failed-400-if-data-gt-1024-bytes/m-p/12774815#M2023280</guid>
      <dc:creator>AnnePetteroe</dc:creator>
      <dc:date>2023-08-28T16:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: CL_HTTP_CLIENT-&gt;request-&gt;set_data failed 400 if data &gt;= 1024 bytes</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cl-http-client-gt-request-gt-set-data-failed-400-if-data-gt-1024-bytes/m-p/12774816#M2023281</link>
      <description>&lt;P&gt;Hi Anton,&lt;/P&gt;&lt;P&gt;Increase the &lt;A href="https://help.sap.com/docs/ABAP_PLATFORM_NEW/683d6a1797a34730a6e005d1e8de6f22/483e87b3ca6b72d0e10000000a42189c.html?locale=en-US"&gt;icm/HTTP/max_request_size_KB&lt;/A&gt; parameter to, for example, 102400&lt;STRONG&gt;0&lt;/STRONG&gt; and try again. As this parameter is defined as "&lt;A href="https://help.sap.com/doc/saphelp_em92/9.2/en-US/68/4eb3c995d44b2aa4ff0140944c06f7/content.htm?no_cache=true"&gt;dynamic&lt;/A&gt;", there is no need to restart the server. &lt;BR /&gt;&lt;BR /&gt;Screenshot from transaction RZ11:&lt;BR /&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2206452-image.png" /&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;BR /&gt;Jim&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2023 06:35:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cl-http-client-gt-request-gt-set-data-failed-400-if-data-gt-1024-bytes/m-p/12774816#M2023281</guid>
      <dc:creator>turkaj</dc:creator>
      <dc:date>2023-08-29T06:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: CL_HTTP_CLIENT-&gt;request-&gt;set_data failed 400 if data &gt;= 1024 bytes</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cl-http-client-gt-request-gt-set-data-failed-400-if-data-gt-1024-bytes/m-p/12774817#M2023282</link>
      <description>&lt;P&gt;You clearly don't execute the same request via ABAP and via "not SAP client", otherwise you'd obtain the same result.&lt;/P&gt;&lt;P&gt;Use SICF &amp;gt; Client Recording to compare the raw HTTP request.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Aug 2023 08:19:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cl-http-client-gt-request-gt-set-data-failed-400-if-data-gt-1024-bytes/m-p/12774817#M2023282</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-08-29T08:19:19Z</dc:date>
    </item>
  </channel>
</rss>

