cancel
Showing results for 
Search instead for 
Did you mean: 

Issue looping through JSON array

zdickson10
Deputy Chef I
Deputy Chef I

I am running an http GET to receive and initial data payload. After the GET, i have a step to cleanse and parse the JSON. These steps appear to be working correctly as i can see all the expected fields and their values from the initial payload. Part of this initial payload is an array of records containing a user ID. 

Following the initial GET, i am running a loop to parse through the array of users, and using the user ID field from the array to run another GET to return the actual user records. However, the ID received from the initial payload is always returning null after the initial GET. It shows as null in the second GET as well as in a workato logger. 

I am able to see the data being received from the initial GET, and if i hardcode the second GET using the ID from the first GET, it works and returns that single user record. However when using the datapill for the ID from the initial GET, it is null in all cases. 

Does anyone know why this might be happening?

 

4 REPLIES 4

manii
Deputy Chef I
Deputy Chef I

Hi, @zdickson10 

It happens when the datapill’s scope or JSON path doesn’t match the actual structure.

Double-check the JSON structure, make sure you loop over the correct array, and that your datapill comes from the parsed JSON step

Bhagya_pola
Executive Chef I
Executive Chef I

Hello @zdickson10 , 

Can you check the schema you defined in the http step, what is the name written in the schema of that pill 

And compare it with the key in json, 

I guess this might be the issue. If not please let me know. 

Rajesh_Nadella
Deputy Chef II
Deputy Chef II

Actual issue is with the schema provided as sample document in the Json parser. 
Better you copy the ouput json from the http response to get the proper schema and paste that in the Sample document of json parser. This will give you the proper data pills to map the id in the next GET protocol of http.
example:
consider this is an output from the HTTP GET:
{
"Telecom": {
"Telephonenumber": "",
"Mobilenumber": "vv",
"Faxnumber": "vfv",
"Mail": "abcc@mail.com",
"Translated telecom segment": [{
"Telephonenumber": "981168200",
"Mobilenumber": "vvfffffg",
"Fax number": "vfv",
"LanguageKey":"ES"
}
]
}
}
Paste this in the json parser where Sample document is box asks for the sample json.
feel free to reach me. If any issues

 

 

 

shivakumara
Executive Chef III
Executive Chef III

Hi @zdickson10 ,

This usually happens when the parsed JSON structure doesn’t match the actual response from the first GET call.

In simple terms — Workato can’t find the user_id field because the schema used in your “Parse JSON” step doesn’t align perfectly with the real data structure coming from the API.

Fix:
Double-check your “Parse JSON” schema — make sure the field names, data types, and nesting levels match exactly with the incoming payload. Once the schema matches, the user_id datapill will populate correctly in the loop.

If possible, could you please paste your Parse Json Sample document/payload provided? 

Thanks and Regards,
Shivakumara K A