cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Returning a result from a callable recipe

edward-abrahams
Deputy Chef I
Deputy Chef I

Hey all, wondering if I could get some advice on using callable recipes. I've set one up where my result schema is a single object. I then have a Python script that also outputs an object (also defined in the Workato schema.) Problem is, when I try and set the result, I can't pick anything. See here:



I can't quite get my head around why it won't accept it seeing as it's all the same type. Any ideas?


Edit: I've found if I change the input schema to text, it will let me pick the data, seems to be the type causing the problem

13 REPLIES 13

roland-daane
Deputy Chef II
Deputy Chef II

Can you share the return snippet in the Python code?

 

Hi Roland, sure:

return {"data": {input["inspection_doc"]["audit_id"]: question_ref}}


question_ref is an array, input["inspection_doc"]["audit_id"] is a string so the output is soemthing like:


{"data": { "audit_123": []}}

Hi,
I thought Iโ€™d just play around a bit, because this is definitely something Iโ€™ll be usingโ€ฆ..
but just a little python script wonโ€™t runโ€ฆ.and the 2 examlpes in the Workato help also donโ€™t workโ€ฆ.

 

Thanks for the link. I had a look and it's because your Python script isn't taking any input. Your script needs to be in a function called main that has input as its parameter. If you change your script to this:


def main(input):

return {"parmRerurn": "Hello World!"}


It'll work fine - even though you haven't defined any inputs, it still passes it to the main function causing the error. Anything you want to get out, needs to be passed to the returned dictionary, named with whatever is in your schema. The inputs go into the input dict so you could reference those if needed.

james-ng
Deputy Chef I
Deputy Chef I

hi, would you share the recipe?