How to omit parameters in a REST request
For my automation project I will have a lot of testsuites and testcases with a lot of combinations. For each testsuite I've entered the necessary parameters to be able to use in each testcase. In ReadyAPI you do that in tab "Projects" on your created webservice.
Now, not all parameters will be filled in for a particular testcase whereas the REST request will send anyways all the parameters as emtpy string.
For this project this is harmful, as an empty string could give an answer, and that isn't what I'm looking for.
Testsuite parameters: name, cbe_number, country, municipality, neighbours, street, housenumber, po_box
Testcase: Search company on name
For this testcase only parameter 'name' will be filled in, but when I send the request, all other parameters are also filled in in the URL. How can I, per testcase, omit the other parameters please?
Thanks in advance.
Solved! Go to Solution.
Select the project, and below you find Custom Properties tab. Add property there (name value pair). But the name should be SERVICE_HOST_PORT and value is your server address with port.
You only need to add a test suite, a test case, and a test step of groovy script and add the already provided content.
I don't think I can simplify more than this.
Hello @nmrao ,
I'm giving you the screenshots of every page with properties and testcases and script and webservice that I filled in and the error message. The error message I receive is now an internale service error, so I guess everything is ready to be copied in the other testcases. If you see somthing that is still not OK, please let me know.
I think you're getting there - but when @nmrao said 'select the project' - he doesn't mean in the 'Projects' tab in ReadyAPI!.
He means within the 'SoapUI' tab, click on the relevant project so focus is highlighting your project - you will see the 'Project properties' and 'custom properties' tabs.
add in 'SERVICE_HOST_PORT' as the name, 'http://10.9.12.23:8080' as the value
You should be good to go - unless there's a problem elsewhere.
finally - Is there any authorization on your project? I just noticed the value you inserted in your screenshot has the http protocol specified - are you sure it's not https?
If this doesn't work, there must be another problem - can you clear your logs (bottom left hand corner of your screen - click on the 'Show Logs' link to expand, then click 'clear all logs') and re-execute the test and upload your logs? (ReadyAPI! log, script log and chuck in the http log as well please fella,
Yes I've noticed that we ( Rao and me) misunderstood eachother. Thanks for your help. You seem to have good people management insights! 😉
For now on this project my architect has given me a mock server to test with as we are just creating the POC (Proof of concept). Meaning that we're not using Authorizations at this point. If the project is agreed (accepted by the client) we will for sure use Authorizations. 😉 I guess I need to come back ans ask Rao to adapt the script with authorizations as the testcases now only contain Groovy Script step?
I've cleared the logs and reran the script:
attached the errorlog
if you there's no authorization and authentication at the moment, I wouldn't worry about it - moving from POC to a real system under test takes time - and there's no point @Rao even thinking of altering the script until you know exactly how you're handling authorization/authentication - its too vast a subject with too many options to worry about it now.
You're getting a http 500 - thats an issue at the server (the app server wherever you're hitting) - thats not a problem at the client (your end).
Way to prove this - in your browser or postman or whatever - submit http://10.9.12.23:8080/agents/organizations?name=uneeq and see what happens.
Rao's script builds your request with the parms you want - but there's no reason you cant test whether the endpoint is working by just submitting the request in postman, browser (or using the ReadyAPI! OTB functionality for a single request)
So - submit the request in postman - does it work? yes - then try groovy script Rao's given you
cheers - I hope I've been clear,
I'm sorry to come back to you...but i can see you've marked MY ANSWER as the solution.
Can you update the post marking @nmrao's instructions as the post that provided the answer, rather than mine please?
This is important so that other people when searching the forum for a similar fix will focus on the correct post and also acknowledge that it was Rao who did all the heavy lifting...not me! 😉
Apparently it's already done. 😉 Indeed, I saw that later that the fact that I accepted your answer as a solution, it became a link under my question. I have accepted his solution also and as I see it now Rao's solution is the only one. Something to bare in mind for me in the futur 🙂
Hello @nmrao ,
Sorry to come back to you but I have one more question for you:
The Groovy Script you gave me only gives the header and query parameter defined on TestCase level in the log Output. How can I, with this Groovy Script, have access to the Endpoint to search those queries please?
thanks in advance.