cancel
Showing results for 
Search instead for 
Did you mean: 

Uploading Image through SAP Gateway Service

mohammed_arshad
Explorer
0 Kudos

Hi Experts,

I am trying to upload image(media) file through SAP Gateway services.

In entity type i check media type.

I redefined CREATE_STREAM method of DPC_EXT

I am trying to upload image as shown in pic.

But i am getting 405 error.

Thanks in advance..

Accepted Solutions (1)

Accepted Solutions (1)

former_member184867
Active Contributor
0 Kudos

Hello Arshad,

The URL you are using is wrong. It should point to the EntitySet. In this case it should be /<YOURSERVICENAME>/EmpPhotoSet.

You need to send a HTTP header called 'SLUG' with the key information. This value you will receive in the CREATE_STREAM method under IV_SLUG parameter. This will be needed to put the image to the correct employee in the backend database tables as there is no other direct mechanism to pass the key information along with the media.

Something like this....

And finally, checking the media flag in service builder and redefining CREATE_STREAM is not sufficient to make it work !!! You need to code 3 lines to enable gateway runtime to handle it.  This can be found in blog by Rashmi BR . That means you need to redefine the DEFINE method of your DPC_EXT and do some code similar to the code available for  DEFINE under link 

If everything is ok so far, you are good to go.

Hope this helps.

Atanu

mohammed_arshad
Explorer
0 Kudos

Hi Mallik,

I followed the steps as you mentioned, Pasted code as in your link forum..

But still i am getting this error[please see image.]

former_member184867
Active Contributor
0 Kudos

This means you are on track now... This is a different error  related to virus scan profile setting.

This is for you http://help.sap.com/saphelp_nw74/helpdata/en/b5/5d22518bc72214e10000000a44176d/content.htm

mohammed_arshad
Explorer
0 Kudos

Hi Mallik,

Thanks for the support, Your answers are helpful.

Thank You.

former_member191161
Participant
0 Kudos

Hello Arshad,

    

         Here your issue resolved i guess...

Now I'm also facing same issue when create file.

I have written code in create_tream method, but I'm getting 'Method not allowed' error(not triggering method).

And where do i pass slug value.

here is my create_stream method.

Kindly, could you please provide me you did that service step by step procedure.

Regards,

Siva R.

Former Member
0 Kudos

Hi Shiva..

You go through with below link for simple operations with media n all..


For SLUG Click on Add Header in HTTP Request.. and add slug Parameter..



CREATE MEDIA


  1. 1.Redefine the DEFINE METHOD OF MPC_EXT CLASS
  2. 2.Paste code.
  3. 3.We need to get key values in SLUG Parameter Of http.
  4. URL.

-------------------------------ZEMP_PRO_SRV/EmpPhotoSet

  1. 4.Click on add file select image.
  2. 5.Check Post method of HTTP.
  3. 5.Execute.

method DEFINE.
super
->DEFINE( ).
DATA:
lo_entity  
type REF TO /IWBEP/IF_MGW_ODATA_ENTITY_TYP,
lo_property
type REF TO /IWBEP/IF_MGW_ODATA_PROPERTY.
lo_entity
= model->GET_ENTITY_TYPE( IV_ENTITY_NAME = 'EmpPhoto' ).

IF lo_entity is BOUND.
lo_property
= lo_entity->GET_PROPERTY( IV_PROPERTY_NAME = 'MIMETYPE' ).
lo_property
->SET_AS_CONTENT_TYPE( ).
ENDIF.
endmethod.




method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_STREAM.

   DATA: ls_key_tab                   TYPE /iwbep/s_mgw_name_value_pair,

         lt_key_tab                   TYPE /iwbep/t_mgw_name_value_pair,

         ls_photo                     TYPE zsemp_photo,

         lv_email                     TYPE char100.

   CASE iv_entity_name.

     WHEN 'EmpPhoto'.

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

       ls_photo-emp_id = iv_slug.

       ls_photo-mimetype = is_media_resource-mime_type.

       ls_photo-filename = 'Test_img'.

       ls_photo-content = is_media_resource-value.

       DELETE FROM zemp_photos WHERE emp_id = ls_photo-emp_id.

       INSERT INTO zemp_photos VALUES ls_photo.

       empphotoset_get_entity(

         EXPORTING

           iv_entity_name     = iv_entity_name

           iv_entity_set_name = iv_entity_set_name

           iv_source_name     = iv_source_name

           it_key_tab         = it_key_tab

           it_navigation_path = it_navigation_path

         IMPORTING

           er_entity          = ls_photo ).

       copy_data_to_ref( EXPORTING is_data = ls_photo

                         CHANGING  cr_data = er_entity ).

   ENDCASE.

endmethod.






Regards,


Arshad Shaikh..

former_member191161
Participant
0 Kudos

Thanks for your response Arshad..


  I followed every step as you said that.

I have been passed slug value. When execute service triggering create_streem method.


But here slug values's tab  "it_key_tab" is shows empty. Why it is not filling.




and finally I am getting this error.



This is my define method.


Regards,

Siva R.


Answers (4)

Answers (4)

former_member191161
Participant
0 Kudos

Hi all,

I'm struggling with photo upload in SAP gateway service.

Could you please provide me step by step procedure of photo upload in SAP gateway service.

Regards,

Siva R.

EkanshCapgemini
Active Contributor
0 Kudos

Hi,

There is one link that is very helpful in creating a service for file upload.This link is good enough to complete the service.

You could have found it easily by simply searching on google or scn.

AshwinDutt
Active Contributor
0 Kudos

Hello Arshad,

U need to pass Keys as part of our header called ' slug ' . Correct ur URL. Refer screen shot.

This shud resolve the error.

Regards,

Ashwin

kammaje_cis
Active Contributor
0 Kudos

Hi Arshad,

Check this blog by

Problem seems to be with your URI.

As Prabhaharan pointed out, make it a practice to search the forums before posting, that would help to keep the forum clutter free.

Regards

Krishna

former_member184739
Contributor
0 Kudos

Hi arshad,

Please do a quick search in this forum on this topic. You will step by step guides. This will address your issues.

Regards

Prabaharan

mohammed_arshad
Explorer
0 Kudos

Hi Prabaharan,

I done quick search but didn't get step by step procedure.

can you plz suggest any step by step procedure link..