Forum Discussion

maxrussell's avatar
maxrussell
Contributor
5 years ago
Solved

Adding a default argument to requests

We are currently using a parameter $format. The default is to specify returning JSON. This can be left empty.

If we want to add a notification to server to use a redirect, we have to add this to the $format parameter, but specifically after the JSON entry, which must be placed at start of string.

 

Is it possible to :

  • create a parameter at a project level which can be applied to all requests
  • can this be selected to use/not use as desired

8 Replies

  • richie's avatar
    richie
    Community Hero
    Hey maxrussell,

    I dont really understand any of the first paragraph im afraid, can you clarify/pad out/add more detail please? You mention you have a $format parm....is this uri/template/resource parm or query parm or matrix parm or header parm?

    I think you indicate the $format parm (whatever type it is) can be empty (no value)....is that correct?

    Next i think you indicate if you want a redirect you have to specify some value in the $format parm....but you state "specifically after the json entry at the start of the string" i have no idea what youre talking about here. Can you rephrase this completely?

    You mention json...do you mean a payload in the request or response?

    In answer to your 2 bullet points the answer is "yes" on both counts.

    Cheers

    Rich
    • maxrussell's avatar
      maxrussell
      Contributor

      Yes - so -

       

      in the test request to our particular endpoint, there is a parameter $format which specifies response type. Default response type is JSON. This is optional to send in the $format request, but it is required when adding the additional redirect portion to the $format string - e.g. JSON&$redirect

      • richie's avatar
        richie
        Community Hero
        Hey maxrussell,

        Sorry, are you saying you have a $format parameter that specifies response type...do you mean datatype so the Content-Type header on your response is 'application/json'?

        Is the parameter a query or uri or header parameter?

        Is there a reason youre using a $format to specify datatype of response cos the standard HTTP header 'Accept' does this already? (Accept header defines the datatype of the response)

        Is the $redirect another uri or query parameter? The way youve written it below it appears as though that redirect is a query parameter....

        Im typing this out on my phone (sp i cant see your original post details whilst responding to your last message), but the standard REST parameters (uri, query, matrix and header) all can be set using variable values (entitled properties in ReadyAPI!/SoapUI) rather than hardcoded values. Is that what you want to do?

        Can you please supply the full URI (NOT the full URL) with all parameters to provide a better understanding of your APIs request please? To cover off security considerations dont include the host/ip address or the username/password in your response, but you can provide the full URI without breaking any of your company's security rules.

        Ta

        Rich