Ask a Question

how to compare multiple database values with api response in single shot without groovy scripting?

SOLVED
Arunachalam_RM
Occasional Contributor

how to compare multiple database values with api response in single shot without groovy scripting?

i have created one table in my sql. i have created one 1 api json response which is coming from my local machine.

now i need to compare response values with databases values as loop.how to do that ?

I add assertion in the request itself.but its comparing all the json values with the last updated mysql database value.

Arunachalam_RM_1-1612179521769.png

 

Arunachalam_RM_0-1612179410948.png

Arunachalam_RM_3-1612179794526.png

 

 

12 REPLIES 12
ChrisAdams
Champion Level 2

Hi,

 

I genuinely cannot think how you might achieve this without any Groovy scripting.  With scripting, it shouldn't be too difficult.

 

I'd be interested to see what the other contributors come up with...

 

Chris

Hey @Arunachalam_RM & @ChrisAdams,


Yep, all i got is groovy. Cant think of any other way to do a compare without it!

Ta

Rich
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
RJ
New Contributor

Hi @Arunachalam_RM

If you have readyapi (Licensed version) then there is one assertion "Mesage Content Assertion", there you can use property transfer to check and configure the values from the Datasource and the response dynamically.

richie
Community Hero

Hey @RJ,

Can you please expand your answer? As far as i was aware the Message Content Assertiom allows you to create multiple assertions against a single response payload, so i'd welcome being educated how to do this if its possible!

@Arunachalam_RM needs to cycle through test responses, but they wont all appear in one payload response...hence the need to cycle. So using the Message Content Assertion wouldnt provide any additional functionality to help Arunachalam_RM do what he needs....it'd be the same as adding in a typical xml content match assertion.

Or am i misunderstanding the requirements?

Also Arunachalam_RM is still gonna need groovy to do the comparison, right?

Cheers,

Rich
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
Arunachalam_RM
Occasional Contributor

every response field ,we need to dynamically set right? (it willl take lot of time?)if i am setting it is taking last value from database

Arunachalam_RM_0-1612444588185.png

 

Arunachalam_RM
Occasional Contributor

Arunachalam_RM_0-1612444675977.png

every field response we need to set the value ah?

 

You can supply a fixed value, but if you're testing the API response matches the datasource value, you should be able to right-click in expected value cell and from the context menu, select Get Data.  Get Data allows you to select a value from anywhere within SoapUI (it's a brilliant little feature).  You could also specify the expected response from your datasource. E.g. {DatasourceStep#value}.  

 

Might be a bit of a pain, but it's Groovy free.  Personally, when managing multiple entries in a single response and rows form a db and looping is required, I'd be more inclined to use Groovy.

RJ
New Contributor

Hi @Arunachalam_RM,

if your query is resolved please mark it as solved, if not then please reiterate your question

Arunachalam_RM
Occasional Contributor

Can u share some groovy to compare API responses against dB?

 

cancel
Showing results for 
Search instead for 
Did you mean: