<?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 Re: attaching file in API using form-data using https with form-data in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/attaching-file-in-api-using-form-data-using-https-with-form-data/m-p/12267696#M1987567</link>
    <description>&lt;P&gt;Hi gaza gazo,&lt;/P&gt;&lt;P&gt;did you solve your problem? I have the same issue and want also to send a PDF via REST Interface.&lt;/P&gt;&lt;P&gt;If you found a solutiuon, could you please post you coding? It will be a great help. Thanks very much.&lt;/P&gt;&lt;P&gt;BR Mouad&lt;/P&gt;</description>
    <pubDate>Wed, 14 Sep 2022 21:05:03 GMT</pubDate>
    <dc:creator>mouad_chemaou</dc:creator>
    <dc:date>2022-09-14T21:05:03Z</dc:date>
    <item>
      <title>attaching file in API using form-data using https with form-data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/attaching-file-in-api-using-form-data-using-https-with-form-data/m-p/12267694#M1987565</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;
  &lt;P&gt;I have requirement to attach the PDF and send some data through HTTPS API using form-data .I am facing issue in connecting .Kindly help on this.&lt;/P&gt;
  &lt;P&gt;CALL METHOD cl_http_client=&amp;gt;create_by_url&lt;BR /&gt; EXPORTING&lt;BR /&gt; url = host&lt;BR /&gt; ssl_id = 'ANONYM'&lt;BR /&gt; IMPORTING&lt;BR /&gt; client = client&lt;BR /&gt; EXCEPTIONS&lt;BR /&gt; argument_not_found = 1&lt;BR /&gt; plugin_not_active = 2&lt;BR /&gt; internal_error = 3&lt;BR /&gt; OTHERS = 4.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;*set http method POST&lt;BR /&gt;&lt;BR /&gt;CALL METHOD client-&amp;gt;request-&amp;gt;set_method(&lt;BR /&gt; if_http_request=&amp;gt;co_request_method_post ).&lt;BR /&gt;&lt;BR /&gt;client-&amp;gt;request-&amp;gt;set_version(&lt;BR /&gt;if_http_request=&amp;gt;co_protocol_version_1_0 ).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;CALL METHOD client-&amp;gt;request-&amp;gt;set_header_field(&lt;BR /&gt; EXPORTING&lt;BR /&gt; name = 'Authorization'&lt;BR /&gt; value = lv_security ).&lt;BR /&gt;&lt;BR /&gt;CALL METHOD client-&amp;gt;request-&amp;gt;if_http_entity~set_content_type&lt;BR /&gt; EXPORTING&lt;BR /&gt;* name = 'content-type'&lt;BR /&gt;* value = 'multipart/form-data'.&lt;BR /&gt; content_type = 'multipart/form-data'.&lt;BR /&gt;&lt;BR /&gt;*CALL METHOD client-&amp;gt;request-&amp;gt;if_http_entity~set_formfield_encoding&lt;BR /&gt;* EXPORTING&lt;BR /&gt;* formfield_encoding = cl_http_request=&amp;gt;if_http_entity~co_encoding_raw.&lt;BR /&gt;&lt;BR /&gt;DATA part TYPE REF TO if_http_entity.&lt;BR /&gt;DATA: it_formulario TYPE tihttpnvp,&lt;BR /&gt; wa_formulario LIKE LINE OF it_formulario.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;part = client-&amp;gt;request-&amp;gt;if_http_entity~add_multipart( ).&lt;BR /&gt;&lt;BR /&gt;CALL METHOD part-&amp;gt;set_header_field&lt;BR /&gt; EXPORTING&lt;BR /&gt; name = 'content-disposition'&lt;BR /&gt; value = 'form-data;name="status"'.&lt;BR /&gt;&lt;BR /&gt;CALL METHOD part-&amp;gt;append_cdata&lt;BR /&gt; EXPORTING&lt;BR /&gt; data = 'Paid'.&lt;BR /&gt;&lt;BR /&gt;part = client-&amp;gt;request-&amp;gt;if_http_entity~add_multipart( ).&lt;BR /&gt;&lt;BR /&gt;CALL METHOD part-&amp;gt;set_header_field&lt;BR /&gt; EXPORTING&lt;BR /&gt; name = 'content-disposition'&lt;BR /&gt; value = 'form-data;name="ucid"'.&lt;BR /&gt;&lt;BR /&gt;CALL METHOD part-&amp;gt;append_cdata&lt;BR /&gt; EXPORTING&lt;BR /&gt; data = '987654321'.&lt;BR /&gt;&lt;BR /&gt;*part = client-&amp;gt;request-&amp;gt;if_http_entity~add_multipart( ).&lt;BR /&gt;&lt;BR /&gt;CALL METHOD part-&amp;gt;set_header_field&lt;BR /&gt; EXPORTING&lt;BR /&gt; name = 'content-disposition'&lt;BR /&gt; value = 'form-data;name="billingMonth"'.&lt;BR /&gt;&lt;BR /&gt;CALL METHOD part-&amp;gt;append_cdata&lt;BR /&gt; EXPORTING&lt;BR /&gt; data = '6'.&lt;BR /&gt;&lt;BR /&gt;*part = client-&amp;gt;request-&amp;gt;if_http_entity~add_multipart( ).&lt;BR /&gt;CALL METHOD part-&amp;gt;set_header_field&lt;BR /&gt; EXPORTING&lt;BR /&gt; name = 'content-disposition'&lt;BR /&gt; value = 'form-data;name="billingYear"'.&lt;BR /&gt;&lt;BR /&gt;CALL METHOD part-&amp;gt;append_cdata&lt;BR /&gt; EXPORTING&lt;BR /&gt; data = '2020'.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;*part = client-&amp;gt;request-&amp;gt;if_http_entity~add_multipart( ).&lt;BR /&gt;CALL METHOD part-&amp;gt;set_header_field&lt;BR /&gt; EXPORTING&lt;BR /&gt; name = 'content-disposition'&lt;BR /&gt; value = 'form-data;name="totalAmount"'.&lt;BR /&gt;&lt;BR /&gt;CALL METHOD part-&amp;gt;append_cdata&lt;BR /&gt; EXPORTING&lt;BR /&gt; data = '29999.98'.&lt;BR /&gt;&lt;BR /&gt;*part = client-&amp;gt;request-&amp;gt;if_http_entity~add_multipart( ).&lt;BR /&gt;CALL METHOD part-&amp;gt;set_header_field&lt;BR /&gt; EXPORTING&lt;BR /&gt; name = 'content-disposition'&lt;BR /&gt; value = 'form-data;name="currencySymbol"'.&lt;BR /&gt;&lt;BR /&gt;CALL METHOD part-&amp;gt;append_cdata&lt;BR /&gt; EXPORTING&lt;BR /&gt; data = '$'.&lt;BR /&gt;part = client-&amp;gt;request-&amp;gt;if_http_entity~add_multipart( ).&lt;BR /&gt;CALL METHOD part-&amp;gt;set_header_field&lt;BR /&gt; EXPORTING&lt;BR /&gt; name = 'content-disposition'&lt;BR /&gt; value = 'form-data;name="currencyCode"'.&lt;BR /&gt;&lt;BR /&gt;CALL METHOD part-&amp;gt;append_cdata&lt;BR /&gt; EXPORTING&lt;BR /&gt; data = 'USD'.&lt;BR /&gt;&lt;BR /&gt;*part = client-&amp;gt;request-&amp;gt;if_http_entity~add_multipart( ).&lt;BR /&gt;CALL METHOD part-&amp;gt;set_header_field&lt;BR /&gt; EXPORTING&lt;BR /&gt; name = 'content-disposition'&lt;BR /&gt; value = 'form-data;name="invoiceType"'.&lt;BR /&gt;&lt;BR /&gt;CALL METHOD part-&amp;gt;append_cdata&lt;BR /&gt; EXPORTING&lt;BR /&gt; data = 'FOD'.&lt;BR /&gt;&lt;BR /&gt;*part = client-&amp;gt;request-&amp;gt;if_http_entity~add_multipart( ).&lt;BR /&gt;CALL METHOD part-&amp;gt;set_header_field&lt;BR /&gt; EXPORTING&lt;BR /&gt; name = 'content-disposition'&lt;BR /&gt; value = 'form-data;name="fileUniqueId"'.&lt;BR /&gt;&lt;BR /&gt;CALL METHOD part-&amp;gt;append_cdata&lt;BR /&gt; EXPORTING&lt;BR /&gt; data = '123456789'.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;*part = client-&amp;gt;request-&amp;gt;if_http_entity~add_multipart( ).&lt;BR /&gt;CALL METHOD part-&amp;gt;set_header_field&lt;BR /&gt; EXPORTING&lt;BR /&gt; name = 'content-disposition'&lt;BR /&gt; value = 'form-data;name="fileName"'.&lt;BR /&gt;&lt;BR /&gt;CALL METHOD part-&amp;gt;append_cdata&lt;BR /&gt; EXPORTING&lt;BR /&gt; data = 'mainfile.txt'.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;*part = client-&amp;gt;request-&amp;gt;if_http_entity~add_multipart( ).&lt;BR /&gt;&lt;BR /&gt;CALL METHOD part-&amp;gt;set_header_field&lt;BR /&gt; EXPORTING&lt;BR /&gt; name = 'content-disposition'&lt;BR /&gt; value = 'form-data; name="file"; filename="mainfile.txt";'.&lt;BR /&gt;&lt;BR /&gt;*CALL METHOD part-&amp;gt;set_content_type&lt;BR /&gt;* EXPORTING&lt;BR /&gt;* content_type = 'applicaiton/text'.&lt;BR /&gt;&lt;BR /&gt;DATA: it_data TYPE xstring,&lt;BR /&gt;&lt;BR /&gt; fichero(140) TYPE c,&lt;BR /&gt;&lt;BR /&gt; len TYPE i.&lt;BR /&gt;&lt;BR /&gt;fichero = '/sapinterface/dev/cic/inbox/invc-batch-sap-eipp-at10/work/mainfile.txt'.&lt;BR /&gt;OPEN DATASET fichero FOR INPUT IN BINARY MODE.&lt;BR /&gt;&lt;BR /&gt;READ DATASET fichero INTO it_data.&lt;BR /&gt;&lt;BR /&gt;len = xstrlen( it_data ).&lt;BR /&gt;CALL METHOD part-&amp;gt;set_data&lt;BR /&gt; EXPORTING&lt;BR /&gt; data = it_data&lt;BR /&gt; offset = 0&lt;BR /&gt; length = len.&lt;BR /&gt;&lt;BR /&gt;CALL METHOD client-&amp;gt;send&lt;BR /&gt; EXPORTING&lt;BR /&gt; timeout = 200&lt;BR /&gt; EXCEPTIONS&lt;BR /&gt; http_communication_failure = 1&lt;BR /&gt; http_invalid_state = 2&lt;BR /&gt; http_processing_failed = 3&lt;BR /&gt; OTHERS = 4.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;CALL METHOD client-&amp;gt;receive&lt;BR /&gt; EXCEPTIONS&lt;BR /&gt; http_communication_failure = 1&lt;BR /&gt; http_invalid_state = 2&lt;BR /&gt; http_processing_failed = 3.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;DATA: lo_request1 TYPE REF TO if_http_request,&lt;BR /&gt; lo_response1 TYPE REF TO if_http_response.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;lo_response1 = client-&amp;gt;response.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Nov 2020 12:45:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/attaching-file-in-api-using-form-data-using-https-with-form-data/m-p/12267694#M1987565</guid>
      <dc:creator>former_member261172</dc:creator>
      <dc:date>2020-11-21T12:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: attaching file in API using form-data using https with form-data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/attaching-file-in-api-using-form-data-using-https-with-form-data/m-p/12267695#M1987566</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;dhandayuthabani.pugazhendhi&lt;/SPAN&gt;&lt;/P&gt;Hi have the same requirement to send a PDF via REST Interface.How did u solved the problem?RegardsG</description>
      <pubDate>Sat, 12 Mar 2022 13:11:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/attaching-file-in-api-using-form-data-using-https-with-form-data/m-p/12267695#M1987566</guid>
      <dc:creator>germain_azambou2</dc:creator>
      <dc:date>2022-03-12T13:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: attaching file in API using form-data using https with form-data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/attaching-file-in-api-using-form-data-using-https-with-form-data/m-p/12267696#M1987567</link>
      <description>&lt;P&gt;Hi gaza gazo,&lt;/P&gt;&lt;P&gt;did you solve your problem? I have the same issue and want also to send a PDF via REST Interface.&lt;/P&gt;&lt;P&gt;If you found a solutiuon, could you please post you coding? It will be a great help. Thanks very much.&lt;/P&gt;&lt;P&gt;BR Mouad&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 21:05:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/attaching-file-in-api-using-form-data-using-https-with-form-data/m-p/12267696#M1987567</guid>
      <dc:creator>mouad_chemaou</dc:creator>
      <dc:date>2022-09-14T21:05:03Z</dc:date>
    </item>
  </channel>
</rss>

