Howdy Automic Community,
I have a job that is using a REST API call that is parsing JSON results in to an array variable from a GET command. Everything is fine, except when there is no data returned from the GET command.
Most of the time data is returned when the job runs, but sometimes there isn't. When there isn't any data to return, my job is failing with the error: "U01001340 The array 'ARRAYVARIABLE#' has not yet been defined.'".
I've tried using an IF statement in the Post-Process to check if the array variable is empty, and then define it, but I get a validation error when trying to define the array in the processing pages (even Pre-Process and Process pages) stating "The total array 'ARRAYVARIABLE#[]' must not be indicated here."
I've also tried to define the array variable in the Variables & Prompts screen, but it doesn't appear to like an array being defined there.
Here is the application/json response when there is no data to return:
--------------------------------------------------
{
"data": [
{
}
]
}
--------------------------------------------------
--------------------------------------------------
My JSONPath Expression:
$.data[*].jobNumber[*]
--------------------------------------------------
--------------------------------------------------
Results (from the Expression Tester):
[]
--------------------------------------------------
But the empty results aren't defining the array variable with the brackets, it's simply not defining the variable at all.
Even if the REST API GET call doesn't have data to return, I'd still like ARRAYVARIABLE# to be defined in some way for further logical evaluation/processing.
Does anyone have any suggestions in handling this or dealt with this before?
I've looked high and low through the documentations and forums, and can't seem to find a workaround or solution for this.
Any help or suggestions would be greatly appreciated!
Thank you for any help!
------------------------------
Will
------------------------------