Skip to Content
avatar image
Former Member

How to send additional parameters with file upload

Hi,

When I upload a file, using SAP GW, de "data" parameter is fileld with the file. However, I'd like to send additional info with the post method.

In the backend the "create_stream" method is called, and I noticed there is an import parameter "IT_KEY_TAB", so it must be possible to send some additonal parameters with the request.

In short: is there anyone who can tell me how I can add a parameter e.g. "Guid" in this post method:

jQuery

     .ajax({

     type : 'POST',

     url : "xxx/sap/opu/odata/sap/ZK_MOBILE_SERVICEDESK_SRV/Files",

     headers : oHeaders,

     cache : false,

     contentType : false,

     dataType : "json",

     processData : false,

     data : file,

          success : function({}),

     ...


Thanks,


RW

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    May 27, 2014 at 10:07 AM

    Hi Robbe,

    I think you have two options:

    1. you can use http request header parameter slug, just insert this into oHeaders and then you will see its value in iv_slug in create_stream. You can make your own logic to separate more fields if you need.

    2. you can add you own request header parameter. And then read it according to solution in this thread

    Best regards,

    Peter

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello Peter,

      I have used http request header parameter slug, but I cannot see any value in iv_slug in create_stream method. Can you guide me on this?

  • avatar image
    Former Member
    May 27, 2014 at 10:10 AM

    IT_KEY_TAB is for different purpose.

    To pass extra parameter you may use a header called SLUG. This will be received in IV_SLUG parameter in the DPC method. If you have multiple things to pass you can pass everything in SLUG separated by some separator 

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 02, 2014 at 03:53 AM

    Hi Robbe,

    If you are posting a file to a navigation property that points at the corresponding media link entityset; then the key fields are filled with the previous entity.

    e.g. Posting a file to Employees('12345')/Attachments will automatically give you the employee id as a key within create_stream.

    Cheers,

    Matt

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 30, 2016 at 03:36 PM

    For some help implementing Matt's suggestion, take a look at Uploading Files to SAP GW, Downloading Files from SAP GW - New Techniques. It allows you to send a number of keys in your URL.

    So things like this are possible using POST:

    Attachments(Key='1234567890',EmployeeNumber='5678',FileName='test.gif')/File

    Add comment
    10|10000 characters needed characters exceeded