Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the response from an API in the dataSet #632

Open
adrian2096 opened this issue Sep 19, 2023 · 3 comments
Open

Use the response from an API in the dataSet #632

adrian2096 opened this issue Sep 19, 2023 · 3 comments

Comments

@adrian2096
Copy link

Hi, I tried to use the JSON response of an Api in the dataSet but I get the message "Caused by: jdk.nashorn.internal.runtime.ParserException: :7:0 Invalid return statement return $output.body;"

dataSet: |
$runAction("org.getopentest.actions.HttpRequest", {
url: url,
verb: GET
});
return $output.body;

Would there be a way to use the API response in the dataSet?

@adrianth
Copy link
Contributor

I never tried it, but I think an IIFE might do the trick:

dataSet: |
  (function() {
    var output = $runAction("org.getopentest.actions.HttpRequest", {
      url: url,
      verb: GET
    });

    return output.body;
  })();

Or a shorter syntax:

dataSet: |
  $runAction("org.getopentest.actions.HttpRequest", {
    url: url,
    verb: GET
  }).body;

Let me know if it worked.

@adrian2096
Copy link
Author

It worked, thanks for the help!

@adrian2096
Copy link
Author

Hello, I am using the solution from this issue and I am seeing that the call is being repeated in each iteration, I was expecting that the call to the dataSet would be made only once, is it possible to change this behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants