Forum Discussion

testspayce's avatar
testspayce
Occasional Contributor
12 years ago

[Res]Bug/feature: keep QUERY params in url when sending file

Hello everyone,
currently you need to check the 'put parameters in body' checkbox when attaching a file in a REST POST request. Why is that? I want to be able to keep the query parameters in the URL, this is logical and the current way is annoying. Is there anything that can be done about it?
Thanks,
Simon

9 Replies

  • Hi Simon,

    Can you attach a screen shot of the 'put parameters in body' checkbox? I do not see that for
    attachments when using a REST POST request. A screen shot would further clarify this.



    Regards,
    Marcus
    Smartbear Support
  • testspayce's avatar
    testspayce
    Occasional Contributor


    Hey Marcus, yes. Here it is.
    Without checking the box we return:
    <Response xmlns="http:/...">
    <description>file stream is null</description>
    <errorCode>-100</errorCode>
    <success>false</success>
    </Response>
    When I check the box, we return:
    <Response xmlns="http:/...">
    <description>session Id required</description>
    <errorCode>-100</errorCode>
    <success>false</success>
    </Response>
    I can't ask to change the API, I don't see why all or none params have to be in the body. Seems a clear difference between file and query params?
    thanks
    Simon
  • Hi Simon,

    I believe what you are trying to achieve can be done by the following way:

    You need to copy the parameters and put them in resource text area.
    Then remove the parameters in the body area.

    Check doc for example screen shot.
  • testspayce's avatar
    testspayce
    Occasional Contributor
    Dear Marcus,
    thank you for your time and effort but the situation is slightly complicated. I cannot make JSON requests, multipart form data is required. I also must put the QUERY parameters in the URL. See below. These are requirements that I cannot readily change.

    <html>
    <head>
    <meta content="HTML Tidy for Java (vers. 26 sep 2004), see www.w3.org" name="generator"/>
    <title>Apache Tomcat/7.0.40 - Error report</title>
    <style type="text/css">&lt;!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style>
    </head>
    <body>
    <h1>HTTP Status 415 - Unsupported Media Type</h1>
    <hr noshade="noshade" size="1"/>
    <p>
    <b>type</b>
    Status report
    </p>
    <p>
    <b>message</b>
    <u>Unsupported Media Type</u>
    </p>
    <p>
    <b>description</b>
    <u>The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.</u>
    </p>
    <hr noshade="noshade" size="1"/>
    <h3>Apache Tomcat/7.0.40</h3>
    </body>
    </html>

    and when I check "Post QueryStr.."
    <Response xmlns="http://..">
    <description>session Id required</description>
    <errorCode>-100</errorCode>
    <success>false</success>
    </Response>
  • Hi,

    The application/json request is irrelevant to what I was trying to convey in the screen shot. I was trying to show that the query params can be put in the Resource instead of the body. You can use multipart form data if that is required for your request. I hope this clears up any confusion. If not let me know.


    Thanks.
  • testspayce's avatar
    testspayce
    Occasional Contributor
    Aw right, I missed that. Looks like some old fashioned handwork then. peace!
  • testspayce's avatar
    testspayce
    Occasional Contributor
    Hey Marcus,
    I just tried your suggestion and it does work, however, if I want to transfer properties, how do I transfer for example a sessionId from the respone to the URL of the following request?
    thanks
    Simon
  • testspayce's avatar
    testspayce
    Occasional Contributor
    Hmm wait, using {parametername} in the resource works even better, and does allow defining them in the request. I can then also transfer the value coming back with one request's response to the next.