Best answer

Json data returned in Python code step

  • 31 January 2023
  • 4 replies
  • 472 views

Hi,  I am putting together a “quick” POC for someone and I have a python code step that calls an api that returns the data in json format.  All I am trying to do is return the data to be used in the next step which saves it to a Google Table.  The json string should look something like this. 

{
"game": {
"di": "left",
"gid": 2022200033,
"hid": 1612709911,
"st": "2023-01-01 20:00",
"tz": -5,
"vid": 1612709918,
"zn": "ET",
"generic": 0
},
"teams": [
{
"ab": "IWA",
"ci": "Iowa",
"colors": [
"#0C2340",
"#236192",
"#78BE21",
"#9EA2A2",
"#FFFFFF"
],
"logo":

"https://nbadatalakedev.blob.core.windows.net/nba/nba_sdk/assets/gleague_1612709911.png",
"na": "Wolves",
"tid": 1612709911,
"isHome": 1
},
{
"ab": "TEX",
"ci": "Texas",
"colors": [
"#0050B5",
"#0C2340",
"#8D9093",
"#FFFFFF"
],
"logo": "https://nbadatalakedev.blob.core.windows.net/nba/nba_sdk/assets/gleague_1612709918.png",
"na": "Legends",
"tid": 1612709918,
"isHome": 0
}
]
}



I have a teams table that I want to add the 2 teams to with a game id for each record appended.  1 row for each team. When I get tot he next step the data is parsed with with both team names in one field, both logos in another etc.  When trying to add to the table it adds all the fields in one row.

I’m not sure how to just return the raw json string from the python code step.  It seems Zapier is expecting dictionaries instead and I can’t pass those directly to Google Sheets.

 

 

I’m fairly new to Zapier and the process I am trying to put together will be edited and run by people who are not developers so I would like to use as little code as possible.

Any help would be greatly appreciated.

 

Thanks,

 

Rhonda

icon

Best answer by Troy Tessalone 31 January 2023, 01:42

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

4 replies

Thanks.  This does seem like the way to go however, I am still kind of unclear on which data to use.  I tried it with two different values that were returned and got two different results.  One of which only added a row for one team. Thanks,  Rhonda

 

Userlevel 7
Badge +14

Hi @RBailey_2 

Did you review the available help article for using the Looping app in Zaps?

https://help.zapier.com/hc/en-us/articles/8496106701453

 

Why do I only see one loop when I test my Zap?

When you test a loop action, the Zap will only create the first loop. It will not create any other loops during the test.

When the Zap runs live, all loops will run and appear in your Zap History.

Thanks.  I missed that.  

 

Rhonda

 

Userlevel 7
Badge +14

Hi @RBailey_2 

Good question.

The Google Tables Zap action you are trying to use does not support line items.

You can add a Looping app step to handle the line items: https://zapier.com/apps/looping/help