Question

Push and Pop with StoreClient

  • 23 April 2024
  • 2 replies
  • 22 views

I have 3 code blocks where I am trying to set up a StoreClient on the first, from inside a loop, push an item onto a stack in the second, then with the 3rd, after a filter for the last iteration, output the full stack, then send it out in an email.

First block outside the Loop:

store = StoreClient('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')
store.set('codes', [])

Second block in the Loop: (codestr is Input Data from a Google Sheet lookup)

store = StoreClient('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx')
codestr = str(input_data['codestr'])
store.list_push('codes',codestr)

Third block after the iteration filter:

output = store.get(‘codes’)
return output

I get this error testing the second step:

Failed to create a run python in Code by Zapier

Your code had an error! Traceback (most recent call last): File "<string>", line 10, in the_function File "/var/task/store_api.py", line 218, in list_push return self.call('patch', BASE_URL, json=data) File "/var/task/store_api.py", line 74, in call raise StoreCallException(json['error']) StoreCallException: Value is not a mapping

I’m pretty sure it’s an issue with the way I am storing them in the list_push(), but I couldn’t find anything in the docs that helped.  Any ideas?  Screenshot of overall Zap flow below.
 

 


2 replies

Userlevel 7
Badge +14

Hi @yeddish 

NOTE: Loops will run in parallel unless configured otherwise.

 

Have you considering using the Storage Zap app instead of a Code step that uses the Storage API?

https://zapier.com/apps/storage/integrations#triggers-and-actions

Counts as 0 Zap Tasks.

The running in parallel thing was something that I hadn’t anticipated.  I’ll have to change the structure of some of my stuff for that.  Thanks for the info.  I will look into how to use that instead.

Reply