How to use data inside a loop?

Hey, guys,

I am working on a workflow that runs a python code to get information from an API from google maps. I am using python, because that is the language I am familiar to. The goal is to transform the data google maps data into a json format and send it to another POST API, that will include this in my database.

So for example:

I get data from google maps and transform to a dataframe like this:
image

I need to transform it to a json format such as:

{ "name": "A.C. Commercial Cleaning Services",
"phone": "19495225473",
"zip": "96910" }

or

{ "name": "Aloha Maids",
"phone": "19496256427",
"address": "4570 Campus Dr Ste 100",
"city": " Newport Beach",
"add_state": "CA",
"zip": "92660" }

And then I transform it on an array with json values (with or without keys) and nothing seems to work

I always get the error:

[info] Error evaluating loop1 (iteration 1): {"error":{"request_id":"7f445be6-e1ad-4273-be13-f66329ef6829","message":"email, phone are missing, at least one parameter must be provided","code":400,"error":"Grape::Exceptions::ValidationErrors","invalid_params":null}}

And my phone always exists. I don't know what I am doing wrong, but I think I not sending the correct values on the loop.

Any idea on how to fix it?

Hey @Bruna_Tourinho.

Within your loop block, you can refer to the loop input, in this case code1.data, as value,

So if you change to {{value.data}} it should run

2 Likes

@MiguelOrtiz thanks! I knew it was something small like this! Worked

1 Like