Ask a Question

How to omit parameters in a REST request

SOLVED
AAB
Regular Contributor

How to omit parameters in a REST request

Hi,

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.

For example:

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.

43 REPLIES 43
nmrao
Champion Level 3

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.



Regards,
Rao.
AAB
Regular Contributor

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.

 

 

customprop7.pngcustomprop2.pngcustomprop3.pngcustomprop4.pngcustomprop5.pngcustomprop6.png

richie
Community Hero

@AAB 

 

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,

 

nice one,

 

rich

 

cheers,

 

richie

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
AAB
Regular Contributor

Hi @richie 

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:

error1.png

attached the errorlog

 

Cheers,

AAB

 

 

richie
Community Hero

Hi @AAB 

 

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,

 

richie

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
nmrao
Champion Level 3

So, can it be marked solved then?


Regards,
Rao.
AAB
Regular Contributor

Hey @richie 

Yes you've been clear. My architect already explained to me how to do so and I'm getting the same answer on the Swagger  UI(a 500 error). He needs to have a look at that.

 

Thanks again for your help @richie  and @nmrao 

I close this post.

richie
Community Hero

Hey @AAB,

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! 😉

Cheers,

richie
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
AAB
Regular Contributor

Hi @richie 

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  🙂  

 

Cheers

AAB

AAB
Regular Contributor

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.

 

Kind Regards,

AAB

cancel
Showing results for 
Search instead for 
Did you mean: