Skip to Content
author's profile photo Former Member
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 a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on 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 a comment
    10|10000 characters needed characters exceeded

  • Posted on 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 a comment
    10|10000 characters needed characters exceeded

  • Posted on 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 a comment
    10|10000 characters needed characters exceeded

  • Posted on 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 a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.