# Trigger NodeRed flow from postman

**URL:** <https://discourse.nodered.org/t/trigger-nodered-flow-from-postman/70294>\
**Category:** General\
**Tags:** http-request\
**Created:** [9 November 2022 02:01 UTC](https://discourse.nodered.org/t/trigger-nodered-flow-from-postman/70294 "2022-11-09T02:01:39Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ihum](https://avatars.discourse-cdn.com/v4/letter/i/f9ae1b/32.png) [@Ihum](https://discourse.nodered.org/u/Ihum)\
**Post date:** [9 November 2022 02:01 UTC](https://discourse.nodered.org/t/trigger-nodered-flow-from-postman/70294/1 "2022-11-09T02:01:39Z")

</div>

I am new to NodeRED and I'm testing out the APIs. I am trying to Post/trigger a flow on nodeRED through postman.

According to the api documentation, something like this should work:

```auto
curl --location --request POST 'http://localhost:1880/flows' \
--header 'Content-Type: application/json' \
--header 'Node-RED-Deployment-Type: full' \
--data-raw 

```

```auto
[
    {
        "id": "01ef5ccf5a7ea370",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "58ffae9d.a7005",
        "type": "debug",
        "z": "01ef5ccf5a7ea370",
        "name": "",
        "active": true,
        "complete": false,
        "x": 550,
        "y": 180,
        "wires": []
    },
    {
        "id": "17626462.e89d9c",
        "type": "inject",
        "z": "01ef5ccf5a7ea370",
        "name": "",
        "repeat": "",
        "once": false,
        "topic": "",
        "payload": "",
        "x": 150,
        "y": 180,
        "wires": [
            [
                "2921667d.d6de9a"
            ]
        ]
    },
    {
        "id": "2921667d.d6de9a",
        "type": "function",
        "z": "01ef5ccf5a7ea370",
        "name": "Format timestamp",
        "func": "// Create a Date object from the payload\nvar date = new Date(msg.payload);\n// Change the payload to be a formatted Date string\nmsg.payload = date.toString();\n// Return the message so it can be sent on\nreturn msg;",
        "outputs": 1,
        "x": 350,
        "y": 180,
        "wires": [
            [
                "58ffae9d.a7005"
            ]
        ]
    }
]

```

But when I send this on postman, I get a `204 No Content` response. And on NodeRED UI, I get the notification:

```auto
The flows on the server have been updated.

```

And i am asked to review changes.  
What I want is to trigger the flow from postman. I can't see anything that allows that in the documentation or perhaps, I am missing something.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [9 November 2022 08:17 UTC](https://discourse.nodered.org/t/trigger-nodered-flow-from-postman/70294/2 "2022-11-09T08:17:50Z")

</div>

> [@Ihum](#):
>
> `The flows on the server have been updated.`

That means you have to do a `deploy`. So do the deploy and try again.

Also,

1. you need to seperate the 'curl' statement from the flow in your post or it will not import
2. the flow you provided only has an `inject` and `debug` node.
3. when posting a flow, put it between three back tic's like  
`````  
your flow  
`````

You can edit your first post and see the changes I made for you.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [9 November 2022 10:22 UTC](https://discourse.nodered.org/t/trigger-nodered-flow-from-postman/70294/3 "2022-11-09T10:22:30Z")

</div>

Doesn't the POST to /flow do a deploy?

If so then should @Ihum just refresh the browser rather than deploy?

The `204 no content` message, however, suggests that the POST is not correctly formatted.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [9 November 2022 10:27 UTC](https://discourse.nodered.org/t/trigger-nodered-flow-from-postman/70294/4 "2022-11-09T10:27:21Z")

</div>

Also if you want the flow to trigger after deploy, the you would need to set the inject to trigger once after 0.1 seconds

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [9 November 2022 10:31 UTC](https://discourse.nodered.org/t/trigger-nodered-flow-from-postman/70294/5 "2022-11-09T10:31:06Z")

</div>

> [@Colin](#):
>
> Doesn't the POST to /flow do a deploy?

Ahh, I didn't notice that when the curl and flow were all as one before I edited the post. Should have reread it with fresh eyes 🙄

---

<div class="post-metadata">

**Author:** ![Ihum](https://avatars.discourse-cdn.com/v4/letter/i/f9ae1b/32.png) [@Ihum](https://discourse.nodered.org/u/Ihum)\
**Post date:** [9 November 2022 15:05 UTC](https://discourse.nodered.org/t/trigger-nodered-flow-from-postman/70294/6 "2022-11-09T15:05:40Z")

</div>

I have edited my flow in original question to a basic flow that prints the date. And on Postman I am posting to `http://localhost:1880/flow`. But I am getting the error:

```auto
{
    "code": "unexpected_error",
    "message": "missing nodes property"
}

```

What does that mean? What do you mean by the post not being properly formatted? Also, how can I automate the triggering of a flow from postman?

---

<div class="post-metadata">

**Author:** ![Ihum](https://avatars.discourse-cdn.com/v4/letter/i/f9ae1b/32.png) [@Ihum](https://discourse.nodered.org/u/Ihum)\
**Post date:** [9 November 2022 15:08 UTC](https://discourse.nodered.org/t/trigger-nodered-flow-from-postman/70294/7 "2022-11-09T15:08:09Z")

</div>

Thank you. I have edited the flow to include `inject, debug and a function`. I have also changed it to `[POST/flow](https://nodered.org/docs/api/admin/methods/post/flow)`, but I am getting the error:

```auto
{
    "code": "unexpected_error",
    "message": "missing nodes property"
}

```

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [9 November 2022 15:10 UTC](https://discourse.nodered.org/t/trigger-nodered-flow-from-postman/70294/8 "2022-11-09T15:10:50Z")

</div>

Hi @Ihum

You mixing together two different actions.

The requests to `/flows` or `/flow` are used to change what flows are currently deployed in the runtime. The payload format used by `/flow` is different to `/flows` - which is why you are getting an error. The docs cover the details of the required format.

However, if you already have the flow deployed in the runtime and you want to be able to trigger it using Postman, then you should modify you flow to start with the `HTTP In` node - so that it can receive an HTTP request from postman.

The cookbook explains how to create HTTP endpoints in Node-RED: [Create an HTTP Endpoint : Node-RED](https://cookbook.nodered.org/http/create-an-http-endpoint)

That said, the Inject node _does_ expose an HTTP endpoint to the editor (which is how the button on the Inject node is able to trigger it). If you use the browser developer tools you should be able to see the request the editor makes when you click the button. If you go that route, you need to know that the Inject node's endpoint is secured using adminAuth. So if you have properly secured the editor, then postman won't be able to trigger it.

---

<div class="post-metadata">

**Author:** ![Ihum](https://avatars.discourse-cdn.com/v4/letter/i/f9ae1b/32.png) [@Ihum](https://discourse.nodered.org/u/Ihum)\
**Post date:** [9 November 2022 15:40 UTC](https://discourse.nodered.org/t/trigger-nodered-flow-from-postman/70294/9 "2022-11-09T15:40:49Z")

</div>

Quick question: If I don't already have the flow deployed in the runtime and I want to be able to deploy and trigger at the same time using Postman, would a `HTTP In` node handle both the deployment and the triggering?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [9 November 2022 16:02 UTC](https://discourse.nodered.org/t/trigger-nodered-flow-from-postman/70294/10 "2022-11-09T16:02:40Z")

</div>

> [@Ihum](#):
>
> would a `HTTP In` node handle both the deployment and the triggering?

No, they are completely separate actions.

If you want to trigger a flow whenever it gets deployed, then you should follow the advise @E1cid gave you earlier today - [Trigger NodeRed flow from postman - #4 by E1cid](https://discourse.nodered.org/t/trigger-nodered-flow-from-postman/70294/4)

---

<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:** [23 November 2022 16:02 UTC](https://discourse.nodered.org/t/trigger-nodered-flow-from-postman/70294/11 "2022-11-23T16:02:56Z")

</div>

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