cancel
Showing results for 
Search instead for 
Did you mean: 

Python Connector -- returning a dictionary

mstuy
Deputy Chef II
Deputy Chef II

Hello!

I want to return a dictionary from the Python connector but I keep getting an error when I do so. Is this possible to do?

3 ACCEPTED SOLUTIONS

meghan-legaspi
Community Manager
Community Manager

Hi @mstuy,

Are you trying to add a user-created library? Here is more documentation on current Python Connector capabilities: https://docs.workato.com/connectors/python.html#usage-inspiration 

 

If you can provide more info on what recipe you are trying to build, I can have someone from our team reach out.

Cheers,
Meghan

View solution in original post

gary1
Executive Chef III
Executive Chef III

"Internal Error" usually means something else is going wrong within your script. I suggest running the script in another IDE to figure it out (better logging and error reporting), or simply start with a simpler script in the Workato action to ensure the basics are correct.

I wrote this simple code to return your intended output and it works perfectly. This suggests your script is crashing elsewhere, or it's not generating the output object the way you expect it to be formatted.

 

 

def main(input):
     return {'output': [{"label": ['a', 'b', 'c'], "label2" : ['d', 'e', 'f']}]}

 

 

Quick note: I didn't write an output schema for the Python action. This is the default output.

gary1_0-1696380691388.png

As an alternative, you can use Ruby or Javascript ; )

View solution in original post

mstuy
Deputy Chef II
Deputy Chef II

Thanks for the reply! 

I got it working*! But the weird this is that I have another recipe that does something similar but for different input lists. I used essentially the exact same code but it throws the internal error for this  second recipe. The strange thing is that if I change the return to a dummy variable but keep the code the same, then there is no error. This makes me believe that there is no error in the logic code. 

I am perplexed because only one of the recipes error when both should work because they are set up the same way.

 

EDIT: Nevermind I figured it out! In my second recipe I was mapping dependent_values to sets and not arrays. Changing the sets to arrays fixed my recipe and I no longer have any errors.

View solution in original post

5 REPLIES 5

mstuy
Deputy Chef II
Deputy Chef II

Thanks for the reply! 

I got it working*! But the weird this is that I have another recipe that does something similar but for different input lists. I used essentially the exact same code but it throws the internal error for this  second recipe. The strange thing is that if I change the return to a dummy variable but keep the code the same, then there is no error. This makes me believe that there is no error in the logic code. 

I am perplexed because only one of the recipes error when both should work because they are set up the same way.

 

EDIT: Nevermind I figured it out! In my second recipe I was mapping dependent_values to sets and not arrays. Changing the sets to arrays fixed my recipe and I no longer have any errors.