-
Notifications
You must be signed in to change notification settings - Fork 505
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
Random number of entries in payload #705
Comments
I would also find this very useful as I would like 1-4 items in a request. My workaround for this is to repeat the payload 4 times and use variable names with the index appended (e.g. val0, val1, val2). I have a beforeRequest javascript function that generates a random number, and I push that many items into the array while referencing the appropriate index for each item. |
Not sure I understand fully - would you like to be able to grab several rows from a CSV file and have the values assigned to variables but those variables become arrays now? e.g.: payload:
- path: "order-lines.csv"
fields:
- "product_number"
- "quantity"
getMultipleRows:
number: 2 # we grab 2 rows at a time, or we could use "min" and "max" for a randomized number of rows And then in a request: - post:
url: /some/endpoint
json:
lines:
- quantity: "{{ quantity[0] }}"
product_number: "{{ product_number[0] }}"
- quantity: "{{ quantity[1] }}"
product_number: "{{ product_number[1] }}" Something like that? |
no, "random-array" should be a new type with min/max as options. |
I see. For that to work we'd need to introduce custom YAML tags for those nodes and/or built-in functions similar to how AWS CloudFormation does it, e.g. with |
Here is what I'm doing for my workaround. There is a possibility of duplicates with this approach. I'm working with a large input CSV and my system needs to be able to handle duplicates.
My
|
Thanks for sharing that @erasmussenBHTP, that's very helpful! We'll need to size up the effort of adding support for tags/functions that operate on the node itself. |
Hi
I would be nice if it was possible to randomize the number of entries in the payload. An example could be orders with a random number of order lines.
Let's say I have some orders:
.. and some lines:
Then it would be nice to be able to randomize the number of order lines, eg. like this:
The text was updated successfully, but these errors were encountered: