2023 Aug 28 5:30 PM
Hello,
I`m using a POST request with a JSON throught CL_HTTP_CLIENT.
Faced the following situation:
When xstrlen( jsonx ) <= 1024
http_rc = 200. "OK"
When xstrlen( jsonx ) > 1024
http_rc = 400. "Incorrect data given"
Tried to send the same data not via SAP client - Result 200. "OK"
Instead of client->request->set_data I used client->request->set_сdata, the result is similar, as soon as the string size exceeds 1024 bytes, I get a 400 response.
icm/HTTP/max_request_size_KB - 102400
What could be the error, am I somehow filling in the data incorrectly?
Where can there be size limits for request data?
DATA: client TYPE REF TO if_http_client.
cl_http_client=>create_by_destination( EXPORTING
destination = 'z_test'
IMPORTING
client = client ).
client->propertytype_logon_popup = if_http_client=>co_disabled.
client->request->set_version( if_http_request=>co_protocol_version_1_1 ).
client->request->set_method( if_http_request=>co_request_method_post ).
client->request->set_header_field( name = 'Accept' value = 'application/json' ).
client->request->set_header_field( name = 'Content-Type' value = 'application/json' ).
client->request->set_header_field( name = 'Authorization' value = |Bearer TokenValue| ).
DATA jsonx TYPE xstring.
json = '{"someLongJSON....}'.
jsonx = cl_abap_codepage=>convert_to(
source = json
codepage = 'UTF-8' ).
DATA(json_lenx) = xstrlen( jsonx ).
client->request->set_data( data = jsonx
offset = 0
length = json_lenx ).
* DATA(get_jsonx) = client->request->get_cdata( ).
CALL METHOD client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
http_invalid_timeout = 4
OTHERS = 5.
IF sy-subrc <> 0.
RAISE connection_error.
ENDIF.
CALL METHOD client->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->response->get_status( IMPORTING code = http_rc ).
l_xml = client->response->get_cdata( ).
ENDIF.
client->close( ).
2023 Aug 28 5:30 PM
Hello Anton,
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 https://community.sap.com/resources/questions-and-answers, as it provides tips for preparing questions that draw responses from our members.
Feel free to take our Q&A tutorial at https://developers.sap.com/tutorials/community-qa.html as well, as that will also help you when preparing questions for the community.
By adding a picture to your profile you encourage your readers to respond.
Kind regards,
Anne
2023 Aug 29 7:35 AM
Hi Anton,
Increase the icm/HTTP/max_request_size_KB parameter to, for example, 1024000 and try again. As this parameter is defined as "dynamic", there is no need to restart the server.
Screenshot from transaction RZ11:
Regards
Jim
2023 Aug 29 9:19 AM
You clearly don't execute the same request via ABAP and via "not SAP client", otherwise you'd obtain the same result.
Use SICF > Client Recording to compare the raw HTTP request.