Forum Discussion

dief123's avatar
dief123
Occasional Contributor
9 years ago

Pass null from excel spreadsheet Datasource into JSON??

Any ideas on how to specify NULL in Excel spreadsheet so it gets transferred to JSON in ReadyAPI, SoapUI NG Pro?

 

JSON:

{"SBCCommunicationDetails": [{
   "CompassionSBCId": "C0028902042",
   "GlobalPartnerSBCId": ${DataSource#GlobalPartnerSBCId},

   "SourceSystem": "SDL",

...

 

I want this field to end up looking like this in JSON -  "GlobalPartnerSBCId": NULL,

However, no matter how I try to specify the NULL in the Excel spreadsheet, it will not populate like this.

I either get "GlobalPartnerSBCId": "NULL", or ""

 

Any ideas?  In the spreadsheet I have tried these values:

 

NULL, blank, {}, [], 0, "NULL", {NULL}

 

 

 

 

 

 

 

 

8 Replies

  • dief123's avatar
    dief123
    Occasional Contributor

    what is best way to set a field to null using JSON in a REST call?

     

    something other than this? 

             "field": null,

    • nmrao's avatar
      nmrao
      Champion Level 3

      Use groovy script to make that property null.

      For example, there is a test case property say property1 with value either "null" or ""

      set_null_to_property.png

       

      And use ${#TestCase#test} in your REST request

      NOTE: You don't need to assign value to test1 variable, you might already have it as property in DataSource step, so use that property.

    • dief123's avatar
      dief123
      Occasional Contributor

      That is exactly how I need to set the field to null:

       "field": null

      My question is how can I bring this NULL into the field from an Excel spreadsheet as a Datasource in SoapUI?

      How do I specify the null in the excel spreadsheet so it fills the field variable with the  word NULL and

      not "field": "NULL"?

       

      • nmrao's avatar
        nmrao
        Champion Level 3

        Have groovy script after the DataSource step.
        For the first line replace it with below line, hoping that it works because never tried:
        def test1 = context.expand('${DataSource#YourFieldPropertyInDataSource}')
        and let the rest of the code  as it is,  shown in the earlier reply and see.