Problem loading .csv data into the .yml file for request body
See original GitHub issueSo the problem is that the “template” variables doesn’t get replaced when running the script.
“Real url” scrabled
home.yml file:
config:
target: "http://someurl.com"
phases:
- duration: 1
arrivalCount: 1
payload:
path: "users.csv"
fields:
- "email"
- "password"
order: "sequence"
processor: "./log.js"
scenarios:
- flow:
- log: "New virtual user running"
- post:
url: "/tokens"
headers:
Content-Type: "application/json"
json:
email: "{{ email }}"
password: "{{ password }}"
beforeRequest: "setJSONBody"
afterResponse: "logHeaders"
users.csv file: (doesn’t matter what the actual data is actually)
email,password
my@email.com,awesomePassword
log.js file:
module.exports = {
setJSONBody: setJSONBody,
logHeaders: logHeaders
}
function setJSONBody(requestParams, context, ee, next) {
console.log(requestParams)
return next(); // MUST be called for the scenario to continue
}
function logHeaders(requestParams, response, context, ee, next) {
console.log(response.body);
return next(); // MUST be called for the scenario to continue
}
Request (when running the test):
{ url: 'http://someurl.com/tokens',
headers: {},
json: { email: '{{ email }}', password: '{{ password }}' },
beforeRequest: 'setJSONBody',
afterResponse: 'logHeaders',
method: 'POST',
timeout: 120000,
}
As you might notice the template variables: '{{ email }}'
and '{{ password }}'
should be replaced by the input data from the .csv
What is wrong here? @hassy by your request I created this issue from the gitter comment I posted
If more information is required please let me know.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Problem loading .csv data into the .yml file for request body #378
So the problem is that the "template" variables doesn't get replaced when running the script. "Real url" scrabled home.yml file: config: ...
Read more >How to access csv data into yml file by storing it in a variable?
I am creating a .yml load scripting file for artillery tool and I am using the payload section which extracts the information from...
Read more >Importing issues from CSV - GitLab Docs
You can import issues to a project by uploading a CSV file with the following ... To import issues, GitLab requires CSV files...
Read more >Request body for Importing contacts with CSV file
Request body for Importing contacts with CSV file ... I am receiving a "Unable to parse the request body as multipart form-data" error....
Read more >Using CSV DATA SET CONFIG - BlazeMeter Docs
The CSV Data Set Config is used to read lines from a file and to split them into variables. The following article elaborates...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The variables do actually get replaced.
beforeRequest
hooks run before the substitutions happen, that’s why you’re seeing the templates in the output from your function.To verify, run
nc -l 10888
in one window, change target to “http://localhost:10888” and run your script. You should see something like:Edit/P.S.: thanks for taking the time to provide a reproducible test case! 😃
@hassy Could you see that above? Thanks