Forum Discussion

cbeltran's avatar
cbeltran
New Contributor
6 years ago

How to use null values in a datadriven approach (xsi:nil="true") from an Excel datasource?

We have a request that needs to pass a null value in a particular scenario. Our requests have an Excel datasource that we use for parameters.   The issue we have, is that we are unable to paramet...
  • cbeltran's avatar
    cbeltran
    6 years ago

    Hi richi and everyone else;

     

    I have to thank you all for you suggestions I appreciate them.  Your ideas guided me towards the solution that I needed. Now it is working. I ended up using the “RequestFilter.filterRequest” as I had to change the request values before submitting it. (not the response, sorry if I did not explained this properly earlier)

     

    Our request data is read from a datasource, sometimes we need to use null values to test different scenarios.

    The idea is to replace a null string representation fed through a data source for the actual null that ready api uses. This needs to be done for every node that needs it before submitting the request

    .

    So, if we have a request has two or five or more nodes that need to send a null value equivalent then, this solution applies no matter the node name, it should work also at any level in the hierarchy, but I have not tested this yet

     

    The objective if to search for the string representing null, in my case it is “>xsi:nil="true"</TagName> using regular expression to target any tagname

     

    The solution consist in creating a RequestFilter.filterRequest and add the following code:

     

    def reqContent = context.requestContent
    def content

    log.info(reqContent)

    content = reqContent.replaceAll(">xsi:nil=\"true\"</[A-Za-z]+>", " xsi:nil=\"true\" />")

    context.requestContent = content

    log.info(content)

     

    Cheers!!!