Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Groovy script fails when context.getValue is used on response captured via JSON Data Bank

Mitra
Mitra Posts: 2

Hi,

In Parasoft SOATest 9.10., I captured the whole response of a RESTful API call in a variable called "responseBody", in JSON DataBank.

Then I tried using the following statement in my Groovy script (inside Response Traffic -> Extension Tool) and I am getting an error:
def responseBody = context.getValue("Generated data Source", "responseBody");

However, when I copy-paste the API response from the literal tab of JSON Data Bank and set the response body to the copy-pasted string response (after escaping quotes everywhere and enclosing the response within double quotes), I get no errors and my test passes.

Why is this happening and what do I need to do differently in order to make my test grab the API responses dynamically and pass? (The copy-pasted way is not dynamic and won't work for me, even though it is passing).

Thanks!

Comments

  • Mitra
    Mitra Posts: 2

    As soon as I posted the question, I found out the answer. :) It was happening due to the 'd' being in lowercase instead of being in uppercase in context.getValue("Generated data Source", "responseBody");

    Thanks!