โ10-02-2023 12:46 PM
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?
Solved! Go to Solution.
โ10-03-2023 04:58 AM
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
โ10-03-2023 05:53 PM - edited โ10-03-2023 05:55 PM
"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.
As an alternative, you can use Ruby or Javascript ; )
โ10-04-2023 08:37 AM - edited โ10-04-2023 03:28 PM
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.
โ10-04-2023 08:37 AM - edited โ10-04-2023 03:28 PM
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.