Return PythonShell output to a http response


I'm somewhat new to NR, but have some python scripts that are triggered via HTTP POSTs to Node Red that are working great. However, I want to complete the transaction by returning the script output to the original http request, and I'm struggling.

It seems I need to get the msg.payload string and convert it to an object and render with a template and return it with a HTTP response, but I've been unsuccessful.

I am able to prove that I've created a msg object with the text of my script output, but the HTTP response continuously outputs to the debug window as "No Response Object"

I've added content-type headers and just want to return the formatted JSON.

Any thoughts?

It might be easier to understand what you are doing if you can share your flow

1 Like

The issue will (probably) be that the python shell is creating a new msg object for its output. The http in and out nodes need the msg.res property to be maintained all the way through. Or it needs to be saved in context, and then rejoined with the python output before going to the http out.

1 Like