Forum Discussion

ncelerier's avatar
ncelerier
New Contributor
7 years ago

Rest - Parameter that is optional and empty value

Hello,

 

We have a rest web service that we would like to test.

 

Let's say that this web service has a parameter called 'type'. I have the following use cases:

 

[1] the parameter is optional and you don't specify it :

- it must return all the entities, whatever their type value is.

- The request is looking like this : GET http://localhost/service/

 

[2] you specify the parameter with an empty value :

- it must return all the entities that have an empty value for type.

- The request is looking like this : GET http://localhost/service/

 

[3] you specify the parameter with a given value :

- it must return all the entities that have the given value for type.

- The raw request is looking like this : GET http://localhost/service/?type=theValue

 

As you can see, use cases [1] and [2] are different, yet the request is the same. I would like [2] to have the following request: GET http://localhost/service/?type=

 

Here are some things that I have read on other posts, but I havn't been able to make it work :

- I tried to set the type parameter as required, but then it is use case [1] that is not working anymore ;

- I tried to use %00 or %80 or nbsp; and tweaking with the request properties such as "Strip whitespaces", "Remove Empty Content", "Entitize Properties"

 

Can someone help me on this problem ?

 

Is there a built-in way to make it work ? Do I need to use a script ?

 

Thank you !

  • Clone your resource or method. Set the parameter as Required for one of the copies and not Required on the other.

  • JHunt's avatar
    JHunt
    Community Hero

    Clone your resource or method. Set the parameter as Required for one of the copies and not Required on the other.

  • ncelerier's avatar
    ncelerier
    New Contributor

    Hello JHunt,

     

    I didn't though about cloning the operation.

     

    It would be nice if there was something built-in rather than using this hack though (like a checkbox that 'Pass this parameter with an empty value').

     

    Thank you for your quick answer !

     

    • AAB's avatar
      AAB
      Regular Contributor

      For starters I do agree with ncelerier.

      Secondly, I have (just at this moment and we're just creating the POC) 3 teststuites with each at least 7 teststeps. If I need to clone (in the future or now) all those teststeps I'm more doing manually testing as I'm automating. Wondering why I let my company buy ReadyAPI licenses....

      this should be an Enhancement on ReadyAPI. It should be possible to send or don't send a parameter in the SOAPUI Pro instead of creating a lot of Projects URL's or cloning each test step.