Hi, I’m trying to iterate through a response and output the item
, but I seem to keep having the same issue. When running the scenario, it fails and gives the following error: error Invalid module output. Expected Object, but found Array
.
I have found other people having the same issue and fixing it by tying to make an object out of it, but I can’t seem to get it to work.
In the code below, you can see my current attempt.
{
"url": "/companies",
"method": "GET",
"qs": {
"size": "{{ parameters.size }}",
"page": "{{ parameters.pageNR - 1 }}"
},
"type": "urlencoded",
"headers": {},
"response": {
"limit": "{{ body.page.totalPages }}",
"output": "{{ item }}",
"iterate": "{{ body.content }}"
},
"pagination": {
"qs": {
"page": "{{(pagination.page - 1)}}"
}
}
}
When I tried fixing it by looking at other people’s examples, I had the following addition to the ouput:
"output": {
"result": "{{ item }}"
},
But as mentioned before, I get the same response.
An example of the API response I get is as follows:
{
"content": [
{
"id": "xxxx",
"name": "xxxx",
"address": {
"street": "xxxx",
"city": "xxxx",
"postalCode": "xxxx",
"country": "xxxx"
},
"website": "xxxx",
"status": "xxxx",
"billOnBehalfOfEnabled": xxxx,
"orderApprovalRequired": xxxx
},
{
"id": "xxxx",
"name": "xxxx",
"address": {
"street": "xxxx",
"city": "xxxx",
"postalCode": "xxxx",
"country": "xxxx"
},
"website": "xxxx",
"status": "xxxx",
"selfServiceAllowed": xxxx,
"billOnBehalfOfEnabled": xxxx,
"orderApprovalRequired": xxxx
}
],
"page": {
"size": 2,
"totalElements": 8,
"totalPages": 4,
"number": 0
}
}