Hi,
I need your collaboration. I have a scenario to do a query using POST to URL. The value you received is stored in the variable “fhybis”.
The received “fhybis” value looks like this:
{
“MT_Consultacliente_CTI_Response”: {
“Customer”: [
{
“InternalID”: 31261,
“PartyTaxID”: “7699998-8”,
“Producto”: “Hormigon”,
“RegionCode”: “013”,
“ZCLASEBP”: “Z000”
},
{
“InternalID”: 31298,
“PartyTaxID”: “76214001-2”,
“Producto”: “Hormigon”,
“RegionCode”: “013”,
“ZCLASEBP”: “”
},
{
“InternalID”: 10066705,
“PartyTaxID”: “23500975-7”,
“Producto”: “Hormigon”,
“RegionCode”: “013”,
“ZCLASEBP”: “”
}
]
}
}
For example if I take one of the InternalID values I use this:
$(rhybis.MT_Consultacliente_CTI_Response.Customer[0].InternalID)
But I need to know the number of records in the array. How do I know how many “Customer” registrations I received?
I was trying something like this, but it didn’t work:
(rhybis.MT_Consultacliente_CTI_Response.Customer.length)
(rhybis.length)
This would not be a length function - length is the character count of a string.
To determine how many responses you have received in the same POST
- Ask the owner of the API to include a count variable at the top - this is by far the easiest, and allows you to minimize the logic in scenario
An example of a common response
{
“__count”:“3”
“MT_Consultacliente_CTI_Response”: {
“Customer”: [
{
“InternalID”: 31261,
“PartyTaxID”: “7699998-8”,
“Producto”: “Hormigon”,
“RegionCode”: “013”,
“ZCLASEBP”: “Z000”
},
{
“InternalID”: 31298,
“PartyTaxID”: “76214001-2”,
“Producto”: “Hormigon”,
“RegionCode”: “013”,
“ZCLASEBP”: “”
},
{
“InternalID”: 10066705,
“PartyTaxID”: “23500975-7”,
“Producto”: “Hormigon”,
“RegionCode”: “013”,
“ZCLASEBP”: “”
}
]
}
}
- If this is not possible, you will iterate through the array, checking to see when you reach NULL
Example
IF statement
scenario variable: $(rhybis.MT_Consultacliente_CTI_Response.Customer[0].InternalID) is not Empty
IF statement
scenario variable $(rhybis.MT_Consultacliente_CTI_Response.Customer[1].InternalID) is not Empty
IF statement
etc.
The first “empty” will tell you when you have reached the end, and allow you to set a count explicitly