Question

using output from Code (Python) in next step

  • 1 March 2023
  • 3 replies
  • 575 views

Userlevel 1

I'm catching a raw webhook and process this input in a Python Code-step. However,  I didn't succeed in using the returned value from the Code-step in a next step.

The provided Python examples don't show screenshots of Zapier, so I still don't know what to do in order to get the data in the next step.

In the code-step I return the right json encoded value


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

3 replies

Userlevel 7
Badge +14

Hi @MarcKraak 

Good question.

Check out this related help article with Python examples: https://help.zapier.com/hc/en-us/articles/8496197130893-Python-code-examples-in-Zaps

 

Introductory Examples

Each of the four examples below expects a name in the "Input Data" field.

A easy example might be something as trivial as:

return {'id': 1234, 'hello': 'world!', 'name': input_data['name']}

You can also bind the result to output—the code above has exactly the same behavior as the code below:

output = {'id': 1234, 'hello': 'world!', 'name': input_data['name']}

An example with an early empty return might be something as trivial as:

if input_data['name'] == 'Larry':
return [] # we don't work for Larry!

return {'id': 1234, 'hello': 'world!', 'name': input_data['name']}

 

Userlevel 6
Badge +8

Hi @MarcKraak!
 

Can you post a screenshot of your Python script or copy/paste it into a code window here? That will help us diagnose what’s going on. My guess is it has to do with your return/output statement syntax.

Userlevel 1

Hi, my Python script contains following 

 

rawdata='<json string........>'
jsonEncodedData = json.loads(rawdata)
# some modifications are done to this json object
output = jsonEncodedData
return output