Showing results for 
Search instead for 
Did you mean: 

POST multi part from SAP Cloud Platform, ABAP Enviroment

0 Kudos


I am trying to POST PDF document content to AWS S3 using SAP Cloud Platform ABAP Environment. I am facing few issues in doing the same. Below are the steps I am trying to achieve.

1. Read the document from S3 using the GET method which I am able to achieve successfully. Now I have the PDF content in my response (response->get_binary() and response->get_text() ).

2. Trying to POST the same document content to S3. This is where I am facing some challenges. As per the API documentation, the required parameters for upload are 'Authentication', 'Path' and 'File' (formdata).

I need to pass the file content using multi part.

Basically I am trying to achieve the same requirement as in ABAP Cloud Environment.

Any pointers will be very helpful.



Accepted Solutions (0)

Answers (1)

Answers (1)

Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Kishore,

for the moment please use following workaround for multipart POST requests:

DATA(lo_dest) = cl_http_destination_provider=>create_by_url( i_url = '' ).
DATA(lo_http_client) = cl_web_http_client_manager=>create_by_http_destination( i_destination = lo_dest ).
DATA(lo_request) = lo_http_client->get_http_request(  ).
DATA(lv_file_name) = 'myFile2.pdf'.
DATA(lv_file_content) = ''.
DATA(lv_file_type) = 'application/pdf'.
DATA(lv_boundary) = 'blob'.

lo_request->set_header_field( i_name = 'Authorization' i_value = '' ).
lo_request->set_header_field( i_name = 'Content-Type' i_value = |multipart/form-data; boundary={ lv_boundary }| ).

DATA(lv_body) = |--{ lv_boundary }\r\n| &&
                |content-disposition: form-data; name="{ lv_file_name }"; filename="{ lv_file_name }"\r\n| &&
                |Content-Type: { lv_file_type }\r\n| &&
                |\r\n| &&
                |{ lv_file_content }\r\n| &&
                |--{ lv_boundary }--|.

lo_request->set_text( lv_body ).
lo_request->set_form_field( i_name = 'path' i_value = |/myDirectory/{ lv_file_name }| ).

DATA(lo_post_response) = lo_http_client->execute( i_method = if_web_http_client=>post ).

Best regards,