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

**URL:** https://discourse.nodered.org/t/how-can-i-pass-python-script-file-and-input-image-folder-path-as-params-using-postman/81830
**Category:** General
**Tags:** function-node, exec
**Created:** [6 October 2023 12:59 UTC](https://discourse.nodered.org/t/how-can-i-pass-python-script-file-and-input-image-folder-path-as-params-using-postman/81830 "2023-10-06T12:59:02Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![Ram1](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@Ram1](https://discourse.nodered.org/u/Ram1)
#### Post date: [6 October 2023 12:59 UTC](https://discourse.nodered.org/t/how-can-i-pass-python-script-file-and-input-image-folder-path-as-params-using-postman/81830/1 "2023-10-06T12:59:02Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [6 October 2023 13:19 UTC](https://discourse.nodered.org/t/how-can-i-pass-python-script-file-and-input-image-folder-path-as-params-using-postman/81830/2 "2023-10-06T13:19:02Z")

</div>

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"

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/a/fab09ff933139a8b9663ad6baf9f5e7321462672.png)

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

---

<div class="post-metadata">

### Author: ![Ram1](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@Ram1](https://discourse.nodered.org/u/Ram1)
#### Post date: [6 October 2023 13:24 UTC](https://discourse.nodered.org/t/how-can-i-pass-python-script-file-and-input-image-folder-path-as-params-using-postman/81830/3 "2023-10-06T13:24:47Z")

</div>

Hi jbudd,

no actually I need to pass the file path in msg.payload  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/5/e591d42ddef107e7e3c6254b793a6ae2b3e6ca93.png)

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.

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [6 October 2023 13:28 UTC](https://discourse.nodered.org/t/how-can-i-pass-python-script-file-and-input-image-folder-path-as-params-using-postman/81830/4 "2023-10-06T13:28:09Z")

</div>

Actually didn't I suggest exactly that?

> [@jbudd](#):
>
> msg.payload = "/path/to/my/image.png"

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [6 October 2023 14:10 UTC](https://discourse.nodered.org/t/how-can-i-pass-python-script-file-and-input-image-folder-path-as-params-using-postman/81830/5 "2023-10-06T14:10:27Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Ram1](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@Ram1](https://discourse.nodered.org/u/Ram1)
#### Post date: [9 October 2023 07:12 UTC](https://discourse.nodered.org/t/how-can-i-pass-python-script-file-and-input-image-folder-path-as-params-using-postman/81830/6 "2023-10-09T07:12:39Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/9/f9035e08ea039a71d38359f8c5cd0c96d97df131.png)

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

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [9 October 2023 07:50 UTC](https://discourse.nodered.org/t/how-can-i-pass-python-script-file-and-input-image-folder-path-as-params-using-postman/81830/7 "2023-10-09T07:50:51Z")

</div>

What have you tried so far?

---

<div class="post-metadata">

### Author: ![Ram1](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@Ram1](https://discourse.nodered.org/u/Ram1)
#### Post date: [9 October 2023 11:07 UTC](https://discourse.nodered.org/t/how-can-i-pass-python-script-file-and-input-image-folder-path-as-params-using-postman/81830/8 "2023-10-09T11:07:48Z")

</div>

As of now I am having python file for generating polygons of solar images. I have stored the python file as test.py. 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.

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [9 October 2023 11:19 UTC](https://discourse.nodered.org/t/how-can-i-pass-python-script-file-and-input-image-folder-path-as-params-using-postman/81830/9 "2023-10-09T11:19:00Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [9 October 2023 11:53 UTC](https://discourse.nodered.org/t/how-can-i-pass-python-script-file-and-input-image-folder-path-as-params-using-postman/81830/10 "2023-10-09T11:53:21Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Ram1](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@Ram1](https://discourse.nodered.org/u/Ram1)
#### Post date: [9 October 2023 11:55 UTC](https://discourse.nodered.org/t/how-can-i-pass-python-script-file-and-input-image-folder-path-as-params-using-postman/81830/11 "2023-10-09T11:55:30Z")

</div>

yes exactly

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [9 October 2023 11:58 UTC](https://discourse.nodered.org/t/how-can-i-pass-python-script-file-and-input-image-folder-path-as-params-using-postman/81830/12 "2023-10-09T11:58:43Z")

</div>

Share your postman as a `curl`

[https://help.mulesoft.com/s/article/How-to-export-Postman-request-as-a-cURL-command-to-help-MuleSoft-Support](https://help.mulesoft.com/s/article/How-to-export-Postman-request-as-a-cURL-command-to-help-MuleSoft-Support)

---

<div class="post-metadata">

### Author: ![Ram1](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@Ram1](https://discourse.nodered.org/u/Ram1)
#### Post date: [9 October 2023 12:06 UTC](https://discourse.nodered.org/t/how-can-i-pass-python-script-file-and-input-image-folder-path-as-params-using-postman/81830/13 "2023-10-09T12:06:14Z")

</div>

curl --location '[http://127.0.0.1:1880/test](http://127.0.0.1:1880/test)'   
--header 'Content-Type: application/json'   
--data '{  
"filepath":"E:\node\_red\imagefootprint\test.py",  
"folderpath":"E:\node\_red\imagefootprint\All\_Photos"  
}'

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [9 October 2023 13:07 UTC](https://discourse.nodered.org/t/how-can-i-pass-python-script-file-and-input-image-folder-path-as-params-using-postman/81830/14 "2023-10-09T13:07:22Z")

</div>

This should get you close.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/9/595abc8950d2c1600c06577b566f4d607206895b.png)

```auto
[{"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 'http://127.0.0.1:1880/test'\n// --header 'Content-Type: application/json'\n// --data '{\n// \"filepath\":\"E:/node_red\\imagefootprint\\test.py\",\n// \"folderpath\":\"E:\\node_red\\imagefootprint\\All_Photos\"\n// }'\n\n// msg.method = \"post\" // set in HTTP Request node\n// msg.url = \"http://127.0.0.1:1880/test\" // set in HTTP Request node\nmsg.payload = { \"filepath\":\"E:/node_red/imagefootprint/test.py\", \"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":"http://127.0.0.1:1880/test","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.

---

<div class="post-metadata">

### Author: ![Ram1](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@Ram1](https://discourse.nodered.org/u/Ram1)
#### Post date: [10 October 2023 11:49 UTC](https://discourse.nodered.org/t/how-can-i-pass-python-script-file-and-input-image-folder-path-as-params-using-postman/81830/15 "2023-10-10T11:49:39Z")

</div>

I need to return the polygons as json output

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [10 October 2023 12:14 UTC](https://discourse.nodered.org/t/how-can-i-pass-python-script-file-and-input-image-folder-path-as-params-using-postman/81830/16 "2023-10-10T12:14:09Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Ram1](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@Ram1](https://discourse.nodered.org/u/Ram1)
#### Post date: [10 October 2023 12:22 UTC](https://discourse.nodered.org/t/how-can-i-pass-python-script-file-and-input-image-folder-path-as-params-using-postman/81830/17 "2023-10-10T12:22:31Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [10 October 2023 12:27 UTC](https://discourse.nodered.org/t/how-can-i-pass-python-script-file-and-input-image-folder-path-as-params-using-postman/81830/18 "2023-10-10T12:27:51Z")

</div>

> [@Ram1](#):
>
> 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.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [9 December 2023 12:28 UTC](https://discourse.nodered.org/t/how-can-i-pass-python-script-file-and-input-image-folder-path-as-params-using-postman/81830/19 "2023-12-09T12:28:37Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
