Forum Discussion

sukanya's avatar
sukanya
Contributor
6 years ago
Solved

How to read JSON file using FileWait

 Hi,

I have used the below code to read the Json file using File Wait step in Ready API:

 

uploaded .json file in File Wait Step

 

def jsonfile = context.expand( '${File Wait#fileContent}' ) 

def baselineResp = new JsonSlurper().parseText(jsonfile ) 

 

But I am getting "Text must not be null" error.

Please do the needful on this.

  • Is your property expansion correct? You can use the right click menu item Get Data to ensure you have the correct value.

     

    Also you could add the following line between your two line to help see what is going on.

     

    def jsonfile = context.expand( '${File Wait#fileContent}' ) 
    log.info(jsonfile)
    def baselineResp = new JsonSlurper().parseText(jsonfile) 

2 Replies

  • Radford's avatar
    Radford
    Super Contributor

    Is your property expansion correct? You can use the right click menu item Get Data to ensure you have the correct value.

     

    Also you could add the following line between your two line to help see what is going on.

     

    def jsonfile = context.expand( '${File Wait#fileContent}' ) 
    log.info(jsonfile)
    def baselineResp = new JsonSlurper().parseText(jsonfile)