How can I pass python script file and input image folder path as params using postman?

How can I pass python script file and input image folder path as params using postman body? and get from exec node as msg.payload and run the script file?

Hello @Ram1, welcome to the forum.

I think you want to know how to run a python script via the exec node, passing parameters.
You can certainly do that by putting the parameters in msg.payload eg msg.payload = "/path/to/my/image.png"

But I do not understand what you mean by "using postman body". Can you explain please?

Hi jbudd,

no actually I need to pass the file path in msg.payload

In this img there is a field called append in that there is a extra input parameter text box. in that text box I need to pass the python file path and input folder path for python file like this [msg.payload.filepath -d msg.payload.inputpath] . Is this possible to run and execute the python file.

Actually didn't I suggest exactly that?

At least if you are on Linux there is no need to have "python" as the command. Instead you can make the python script executable and use a "hashbang" or "shebang " line at the top of the file to tell the shell where to find the python interpreter. Google bash hashbang for more info.

If you want to you can leave the command field blank and put "python /usr/bin/scriptname /home/pi/.node-red/images/picture.jpg" in msg.payload

I need to give python filepath and input folder path like this in postman.

the execute node should be able to get these filepath and folderpath and need to deliver the output.

What have you tried so far?

As of now I am having python file for generating polygons of solar images. I have stored the python file as and I have stored multiple solar images in one folder. Now I need to pass the python file path and input solar images folder path through postman body as json. That python file and input folder should be executed through node-red. Is this possible? And want to make response api.

You didn't explain what postman is, but it's obviously something I don't know about.

Looks like you are on Windows while I only use Node-red in Linux.

Clearly I'm not the right person to be helping you. No doubt someone else can.

Please explain what your full execution path looks like.

For example, are you intending on using Postman to trigger a Node-RED flow?

Or are you intending Node-RED to act like postman (and call out to an external HTTP endpoint)?

At a guess: you want to trigger postman and have Node-RED receive some data or parameters, then for node-red to execute the specified python and return the results? with a status code of 200 for succees?

yes exactly

Share your postman as a curl

curl --location ''
--header 'Content-Type: application/json'
--data '{

This should get you close.

[{"id":"01c58f6780f2bca6","type":"inject","z":"1ca1817447127d22","name":"Click me","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":740,"y":1360,"wires":[["01cf58bcac76275f"]]},{"id":"01cf58bcac76275f","type":"function","z":"1ca1817447127d22","name":"Prepare Req","func":"// original curl:\n// curl --location ''\n// --header 'Content-Type: application/json'\n// --data '{\n// \"filepath\":\"E:/node_red\\imagefootprint\\\",\n// \"folderpath\":\"E:\\node_red\\imagefootprint\\All_Photos\"\n// }'\n\n// msg.method = \"post\" // set in HTTP Request node\n// msg.url = \"\" // set in HTTP Request node\nmsg.payload = { \"filepath\":\"E:/node_red/imagefootprint/\", \"folderpath\":\"E:/node_red/imagefootprint/All_Photos\" }\nmsg.headers = {\n    \"Content-Type\": \"application/json\"\n}\nmsg.cookies = null\nreturn msg","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":900,"y":1360,"wires":[["18934d909e2b7e17"]]},{"id":"18934d909e2b7e17","type":"http request","z":"1ca1817447127d22","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":1080,"y":1360,"wires":[["e3bfe32460731038"]]},{"id":"e3bfe32460731038","type":"debug","z":"1ca1817447127d22","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1260,"y":1360,"wires":[]},{"id":"3be22cdf9fbf4d48","type":"comment","z":"1ca1817447127d22","name":"Your curl as a flow","info":"","x":770,"y":1320,"wires":[]},{"id":"54f2775e139a7ab5","type":"http in","z":"1ca1817447127d22","name":"","url":"/test","method":"post","upload":false,"swaggerDoc":"","x":730,"y":1460,"wires":[["074c6e4b59345683"]]},{"id":"fc06c214b41b320d","type":"http response","z":"1ca1817447127d22","name":"","statusCode":"200","headers":{},"x":1260,"y":1500,"wires":[]},{"id":"d70b58b741ed1110","type":"comment","z":"1ca1817447127d22","name":"Create an endpoint","info":"","x":770,"y":1420,"wires":[]},{"id":"074c6e4b59345683","type":"change","z":"1ca1817447127d22","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[]","tot":"json"},{"t":"set","p":"payload[0]","pt":"msg","to":"req.body.folderpath","tot":"msg"},{"t":"set","p":"payload[1]","pt":"msg","to":"req.body.filepath","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":1540,"wires":[["a58ffbf473dfce6f","34e16093eaaf5551"]]},{"id":"a58ffbf473dfce6f","type":"exec","z":"1ca1817447127d22","command":"dir","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":1030,"y":1540,"wires":[["fc06c214b41b320d"],["3d9d07f05c08e13f"],[]]},{"id":"34e16093eaaf5551","type":"debug","z":"1ca1817447127d22","name":"debug 309","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1000,"y":1600,"wires":[]},{"id":"3d9d07f05c08e13f","type":"http response","z":"1ca1817447127d22","name":"","statusCode":"400","headers":{},"x":1260,"y":1560,"wires":[]}]

You will need to change the exec to call python and maybe change the "change node" about.

NOTE: always use / instead of \ in your paths.

I need to return the polygons as json output

And what have you tried?

@Ram1 - I mean no offence here but you provide so little detail it is almost impossible to help you.

Remember - we cannot see you screen, we dont know what the data looks like, we dont know where these polygons come from. You havent said what works / what fails etc etc.

I have the python script to generate the polygons from solar images. If I execute the python script directly using execute node from node-red means its working fine. Now what I need is to pass the python script and input images for python script as parameters using postman. how to do this?

Did you try the example I posted yesterday? Did you update exec node like i said? What did you see? Show us.

Remember, we dont know what your python does, we dont know what parameters it expects (and in what order) we dont know what it returns.

As I said before - you do NOT provide enough information to help you.