on ‎2019 Mar 04 1:27 PM
Hi,
I have a strange problem using cl_http_client. I want to do a mulitpart POST, but SAP (maybe the ICM?) reorders the HTTP headers I add using CALL METHOD lo_multipart->set_header_field and also adds Content-Length.
So even if I add the headers in the order 1: Content-Disposition 2: Content-Type, the outgoing request will contain it in another order and Content-Length added:
1: Content-Type 2: Content-Length 3: Content-Disposition.
Using lo_multipart->suppress_content_type does not change anything either.
However, the external platform I'm interfacing with is sensitive to the order of headers, and will NOT work, if Content-Disposition is not the first header.
Is it possible to configure or turn off this behavior of SAP?
Please check the example below.
Thanks and best regards,
Tamás
ABAP Code:
...
lo_multipart = lo_http_client->request->if_http_entity~add_multipart( ).
CALL METHOD lo_multipart->suppress_content_type EXPORTING suppress = 'X'.
CONCATENATE 'form-data; name="file"; filename="' iv_filename '";' INTO lv_form_value.
*
CALL METHOD lo_multipart->set_header_field
EXPORTING
name = 'Content-Disposition'
value = lv_form_value.
CALL METHOD lo_multipart->set_content_type
EXPORTING
content_type = iv_content_type.
CALL METHOD lo_multipart->set_data
EXPORTING
data = iv_xstring.
...
Outgoing HTTP request:
--F2814BF8064476F37754F550F04B29960
Content-Type: text/html
Content-Length: 8925
content-disposition: form-data; name="file"; filename="SU53_output_passed_INC-000444_S72_20190227.html";
<html dir="ltr"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Report output</title> <style>table.list { border-collapse: collapse; }</style> </head> <!script!> <body bgcolor="#E8EAD8"> ... DATA
Request clarification before answering.
I do not have experience with a "multipart" so excuse me if it is wrong idea. But what if you set headers with lo_http_client->request instead of lo_multipart ?
Also have you tried to use this parameter?
IF_HTTP_ENTITY~ADD_MULTIPART method with parameter SUPPRESS_CONTENT_LENGTHinstead of:
lo_multipart->suppress_content_type methodAlso you can try set_header_fields instead of set_header_field. But it will probably also will be reordered 😞
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Tomas,
You've made my day!!! At least partly 🙂 I overlooked the "suppress_content_length" parameter, thanks for pointing that out.
As Content-Type was mandatory in the external system, I had to do another trick: add two headers into one line... this way SAP does not reorganize it :DD
Now everything works as expected: Integration of SAP and Efecte ITSM systems: https://youtu.be/N7BFkcty-XI
Have a nice day!
Cheers,
Tamás
| User | Count |
|---|---|
| 8 | |
| 7 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.