cancel
Showing results for 
Search instead for 
Did you mean: 

How to Ignore null values in the POST Request

SOLVED
Highlighted
Contributor

How to Ignore null values in the POST Request

Hi

 

Below is my sample request for the POST Request,  in the below request some times the table name values comes as empty or null, so while sending the request i want to ignore this null or empty values, is there a way in readyapi where we can ignore?

 

 

 

{
"tables_list" : [
"${#TestCase#Table1}",
"${#TestCase#Table2}",
"${#TestCase#Table3}",
"${#TestCase#Table4}",
"${#TestCase#Table5}",
"${#TestCase#Table6}",
"${#TestCase#Table7}",
"${#TestCase#Table8}",
"${#TestCase#Table9}",
"${#TestCase#Table10}",
"${#TestCase#Table11}",
"${#TestCase#Table12}"
],

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Leader

Re: How to Ignore null values in the POST Request

@doubtsreadyapi  You can try like this 

 

sBuild.append("\"\${#TestCase#Table1}\"")

 

hope it will work. 🙂


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal

View solution in original post

23 REPLIES 23
Highlighted
Community Hero

Re: How to Ignore null values in the POST Request

How Is that affecting your testing?


Regards,
Rao.
Highlighted
Contributor

Re: How to Ignore null values in the POST Request

Hi @nmrao 

 

Since its going with null or empty values, once the request is posted, in backend jobs are running because of this null values its getting failed.

 

So when the table names are null we must ignore while sending the POST request.

Highlighted
Community Hero

Re: How to Ignore null values in the POST Request

Empty value can affect, but not null. Can show clearly the raw request (text format)?


Regards,
Rao.
Community Hero

Re: How to Ignore null values in the POST Request

Highlighted
Contributor

Re: How to Ignore null values in the POST Request

@nmrao 

 

Thanks for the update.. The link you have provided doesn't help. because my requirement is POST method, and i am getting the data from the custom properties in my Request payload,

 

Highlighted
Community Hero

Re: How to Ignore null values in the POST Request

Hey @doubtsreadyapi,

Ive only just seen this post. Apologies.
Im not understanding. You say the table names are null but this is a POST request. I dont understand why if its a POST the tables names are null. Dont you control whats going in your POST?
I might be able to help if i understand your issue properly.

Cheers fella,

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
Highlighted
Contributor

Re: How to Ignore null values in the POST Request

Hi @richie 

 

Thanks for the update..

 

Here are the steps i am following

Step 1: I am doing JDBC connection and getting the list of tables.

Step 2: using groovy script using json node value i am picking random tables and storing in custom variables.

Step3: what ever the tables i stored in Custom variables i am using in my POST request.

 

So in Step 2: some times the JSON node will return null or empty table names. So while posting the POST request i am sending the Table names with NULL or empty. Because of that in backend jobs are failing since we are sending the parameter with NULL or empty. so i want to know while sending the POST request i dont want to send the values which are NULL or empty.

 

Hope this is understandable.

Highlighted
Community Leader

Re: How to Ignore null values in the POST Request

@doubtsreadyapi :

 

Then you apply a logic at Step 2 (Groovy Step) not to store empty values to custom properties.

 

If need help in that please share you code 🙂


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
Highlighted
Contributor

Re: How to Ignore null values in the POST Request

@HimanshuTayal 

 

Thanks for the update. I am already doing that where as my post request contains reference of those tables.

As i said earlier, Some times what ever the JSON node values i am picking in the groovy script will come as null or empty values.

 

For example, The table one some times i will get value and some times i will get as null or empty.

 

Where as in my POST request payload i am calling the table 1, 

 

Hope its understandable.

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors