Quantcast
Channel: SCN : All Content - SAP Gateway
Viewing all articles
Browse latest Browse all 2823

Not able to upload file via OData Gateway services

$
0
0

Hi,

 

I have created an OData service for File Upload and Download.

I have created 2 tables i.e. 1st Table contains contact information and 2nd table contains the attachment. The Ref_ID field is the primary key in both tables. Using the same Tables I have created the below two Entity Types with Association/Navigation Between Them. I have marked the Second Entity as Media Type

 

Entity 1:

Image 2.JPG

Entity 2:

image4.JPG

 

Image3.JPG

 

I have Implemented the Create Stream Method as below:

 

DATA: ls_key_tab                   TYPE /iwbep/s_mgw_name_value_pair,

             lt_key_tab                   TYPE /iwbep/t_mgw_name_value_pair,

             ls_info                     TYPE ZBASIC_CONT_FILE,

             lv_refid                     TYPE zref_id.

 

   CASE iv_entity_name.

     WHEN 'ZBASIC_CONT_POA_FILE'.

       READ TABLE it_key_tab WITH KEY name = 'RefID' INTO ls_key_tab.

       SELECT SINGLE * FROM zbasic_cont_file INTO CORRESPONDING FIELDS OF ls_info WHERE ref_id = ls_key_tab-value.

       ls_info-ref_id = ls_key_tab-value.

       ls_info-poa_mtype = is_media_resource-mime_type.

       ls_info-poa = iv_slug.

       ls_info-poa_content = is_media_resource-value.

 

       MODIFY zbasic_cont_file FROM ls_info.

 

       copy_data_to_ref( EXPORTING is_data = ls_info

                         CHANGING  cr_data = er_entity ).

   ENDCASE.


While I executing the URL as below with Content-Type = application/atom+xml everything seems to be fine whereas when i set the Content-Type = application/pdf or any thing elsee eror is triggered as in below screenhot.


Error Screen:

image 5.JPG


Sucess Screen with Content Type as application/atom+xml

Image1.JPG


Kindly help to understand What am i doing wrong.


I have followed the Blog

http://scn.sap.com/community/gateway/blog/2014/07/25/uploading-files-to-sap-gw-downloading-files-from-sap-gw--new-techniques



Thanks in advance,

Samir


Viewing all articles
Browse latest Browse all 2823

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>