# \[Noob\] Http post to Rpinotify

**URL:** https://discourse.nodered.org/t/noob-http-post-to-rpinotify/1234
**Category:** General
**Created:** [2 July 2018 12:30 UTC](https://discourse.nodered.org/t/noob-http-post-to-rpinotify/1234 "2018-07-02T12:30:42Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![EnricoSx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/enricosx/32/945_2.png) [@EnricoSx](https://discourse.nodered.org/u/EnricoSx)
#### Post date: [2 July 2018 12:30 UTC](https://discourse.nodered.org/t/noob-http-post-to-rpinotify/1234/1 "2018-07-02T12:30:42Z")

</div>

Hello, sorry for my noob question,  
i want use  
[https://rpinotify.it/invio-di-testo.html](https://rpinotify.it/invio-di-testo.html)  
but i can’t send post message :  
(i edit http: for new user limit post)

my flow:  
inject: with string text=“my message”

http request:  
POST  
URL: [https://api.rpinotify.it/message/secret\_\_key/](https://api.rpinotify.it/message/secret__key/)

Debug:

```auto
2/7/2018, 14:27:27node: 71562e38.b607
msg : Object
object
_msgid: "6ba64316.5fed7c"
topic: ""
payload: "text = prova"
2/7/2018, 14:27:27node: 71562e38.b607
msg : Object
object
_msgid: "6ba64316.5fed7c"
topic: ""
payload: "{"info": {"datetime": "2018-07-02 12:27:27", "ip": "54.149.86.44, 108.162.246.239"}, "message": "'text' or 'img' POST parameter are required", "response": 400}"
statusCode: 400
headers: object
date: "Mon, 02 Jul 2018 12:27:27 GMT"
content-type: "text/html; charset=utf-8"
transfer-encoding: "chunked"
connection: "close"
set-cookie: array[1]
contenttype: "application/json"
x-content-type-options: "nosniff"
expect-ct: "max-age=604800, report-uri="https//report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct""
server: "cloudflare"
cf-ray: "43411b48ce952a8b-SEA"
x-node-red-request-node: "6a8695e6"
responseUrl: "https//api.rpinotify.it/message/secret__key/"
responseCookies: object
__cfduid: object
expires: "Tue, 02-Jul-19 12:27:27 GMT"
path: "/"
domain: ".rpinotify.it"
value: "dac023f71cfd378a6e57f9634072f5db01530534447"

```

---

<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: [2 July 2018 13:57 UTC](https://discourse.nodered.org/t/noob-http-post-to-rpinotify/1234/2 "2018-07-02T13:57:24Z")

</div>

So…have you looked at what is in the payload from the debug?

---

<div class="post-metadata">

### Author: ![EnricoSx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/enricosx/32/945_2.png) [@EnricoSx](https://discourse.nodered.org/u/EnricoSx)
#### Post date: [2 July 2018 14:01 UTC](https://discourse.nodered.org/t/noob-http-post-to-rpinotify/1234/3 "2018-07-02T14:01:03Z")

</div>

> [@zenofmud](#):
>
> So…have you looked at what is in the payload from the debug?

can you kindly explain yourself?

---

<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: [2 July 2018 15:35 UTC](https://discourse.nodered.org/t/noob-http-post-to-rpinotify/1234/4 "2018-07-02T15:35:42Z")

</div>

Look thru the results of the debug you have provided and find the part that says  
payload:…  
what does it say?

---

<div class="post-metadata">

### Author: ![EnricoSx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/enricosx/32/945_2.png) [@EnricoSx](https://discourse.nodered.org/u/EnricoSx)
#### Post date: [3 July 2018 05:02 UTC](https://discourse.nodered.org/t/noob-http-post-to-rpinotify/1234/5 "2018-07-03T05:02:43Z")

</div>

Payload is correct for me  
payload: “text = prova”  
Can you explain me ?

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [3 July 2018 06:34 UTC](https://discourse.nodered.org/t/noob-http-post-to-rpinotify/1234/6 "2018-07-03T06:34:39Z")

</div>

There are 2 messages in that debug you pasted. Look at the second payload

---

<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: [3 July 2018 08:15 UTC](https://discourse.nodered.org/t/noob-http-post-to-rpinotify/1234/7 "2018-07-03T08:15:59Z")

</div>

Just to be a bit more explicit - the second message in the debug output you’ve shared has a payload which is the response from the rpinotify api. It includes an error message telling you what is wrong with the request you’ve made.

Rather than set `msg.payload` to the String `text = prova`, try configuring the Inject node to send an Object (pick ‘JSON’ in the list of types) of `{ "text": "prova" }`. By default, the HTTP Request node will send that as `application/json` content. The API _might_ accept that. If it doesn’t, then you’ll need to set the content-type to form-urlencoded. To do that, use a Change node to set `msg.headers["content-type"]` to the String `application/x-www-form-urlencoded`

---

<div class="post-metadata">

### Author: ![EnricoSx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/enricosx/32/945_2.png) [@EnricoSx](https://discourse.nodered.org/u/EnricoSx)
#### Post date: [3 July 2018 08:54 UTC](https://discourse.nodered.org/t/noob-http-post-to-rpinotify/1234/8 "2018-07-03T08:54:02Z")

</div>

> [@knolleary](#):
>
> application/x-www-form-urlencoded

yeah!  
the problem is  
"To do that, use a Change node to set msg.headers["content-type"] to the String application/x-www-form-urlencoded"

😃

---

<div class="post-metadata">

### Author: ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)
#### Post date: [8 October 2018 21:31 UTC](https://discourse.nodered.org/t/noob-http-post-to-rpinotify/1234/9 "2018-10-08T21:31:27Z")

</div>

OH, and another problem is that if you use the `change` node to set `msg.headers["Content-type"]` with a **Capital 'C'** , the incoming msg.payload is empty!

There goes another hour... and a good bit of my remaining hair! Shouldn't the behavior of the http nodes not be dependent on the correct case of any headers?

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [8 October 2018 23:20 UTC](https://discourse.nodered.org/t/noob-http-post-to-rpinotify/1234/10 "2018-10-08T23:20:23Z")

</div>

what is handling the request at the other end ?

---

<div class="post-metadata">

### Author: ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)
#### Post date: [9 October 2018 00:41 UTC](https://discourse.nodered.org/t/noob-http-post-to-rpinotify/1234/11 "2018-10-09T00:41:01Z")

</div>

That would be the `http in` node inside the same instance of node-red -- which in this case would have worked, I think, if it wasn't for the mangled request url (missing the host:port)

On the receiving side I have this:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/09b56269479f30f01d75a216995c27403e6e2756.png)

and the sending flow's `http request` _seems_ to reference it, using this config:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/ca9a991b0f19ff53983c64a3698c4044151de2be.png)

If I use a relative url in the `http request` node, I get a 404 error, with this responseUrl: `http:///zippi/users` which explains the 404 not found error -- this is a separate issue I mentioned on slack.

But, while trying to describe the problem here, I'm not seeing the same behavior -- of course. So it must be related to the fact that upstream from this `http request` is another `http request` node that is muddying the wires... or at least my request headers. What is the best practice for cleaning up a msg object between requests?

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [9 October 2018 08:22 UTC](https://discourse.nodered.org/t/noob-http-post-to-rpinotify/1234/12 "2018-10-09T08:22:16Z")

</div>

The request node is like a browser - if you type /foo into a browser it won't go to [http://localhost:1880](http://localhost:1880) either...  
Depends how clean you need it - a change node to delete msg.res and msg.headers may be enough. Or a function node to return a completely clean object.  
Not sure re Capital C - we do send it out with whatever capitalisation you set... - but the http in node seems to flatten it to lowercase anyway so shouldn't be an issue.

Do you have a simple demo flow that shows the problem ?

---

<div class="post-metadata">

### Author: ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)
#### Post date: [9 October 2018 20:11 UTC](https://discourse.nodered.org/t/noob-http-post-to-rpinotify/1234/13 "2018-10-09T20:11:36Z")

</div>

> [@dceejay](#):
>
> The request node is like a browser - if you type /foo into a browser it won't go to [http://localhost:1880](http://localhost:1880) either...

That is true, when typing into the browser... but not strictly true, when you are talking about html components. Any element with `src="/foo"` is considered to be relative to the current host:port -- and any url without a leading slash is relative to the current page's url.

This behavior is built-in to many web components:  
`<style href="/my/styles/xyz.css">`  
`<img src="./image/local.jpg">`  
`<form action="/upload/page.html">`  
`<button onclick="myjs/logic.js">`  
etc.

But since the http request is being made from the server's runtime, I guess there is no url context that can be used to "build up" a relative request uri into an absolute url? The runtime knows its own host:port info, doesn't it? Although many host dns names could map to the same server, and reverse proxies could be even more confusing...

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [9 October 2018 20:26 UTC](https://discourse.nodered.org/t/noob-http-post-to-rpinotify/1234/14 "2018-10-09T20:26:18Z")

</div>

correct - as you point out - this isn't inside a web component - this is a request client.  
You can of course pass in the url to the nodes so you can make it as dynamic as you like.
