I’m trying to collect a variable from the response array, but can’t access the array/variable in the test script correctly.
I have a list of tasks with their ids stored in a csv file. I’m looping through all the tasks with a request that gives me the checklists and their ids on the store card from Meistertask API.
what I’m struggling with is storing these checklists ids into a variable using:
var bodyData = JSON.parse(responseBody);
value = bodyData.datax[0].id
console.log
There was an error in evaluating the test script: TypeError: Cannot read properties of undefined (reading ‘0’)
I can’t access the array or get the value of the “id”:
this is the response I get from the request https://www.meistertask.com/api/tasks/{{task_id}}/checklists?items=6
[
{
"id": 54036003,
"name": "Broadband",
"sequence": 0.0,
"task_id": 114372340,
"project_id": 6023397
},
{
"id": 54036005,
"name": "Cabling Site Survey",
"sequence": 15000.0,
"task_id": 114372340,
"project_id": 6023397
},
{
"id": 54036006,
"name": "Constraints",
"sequence": 30000.0,
"task_id": 114372340,
"project_id": 6023397
},
{
"id": 54036007,
"name": "Install, Test & Turn-Up",
"sequence": 45000.0,
"task_id": 114372340,
"project_id": 6023397
},
{
"id": 54036008,
"name": "Porting ",
"sequence": 60000.0,
"task_id": 114372340,
"project_id": 6023397
},
{
"id": 54036010,
"name": "TEMNS - MES - Day Two Support",
"sequence": 75000.0,
"task_id": 114372340,
"project_id": 6023397
}
]
I have tried multiple methods on the community posts, but none worked. I tried the JSON path finder but that doesn’t work either.
I want to collect these checklists ids to a csv file so that I can use them into a delete request that will loop through all these ids to delete them as we are trying to get rid of these checklists from the cards in the project.