Hi guys, I am having a problem with "http-in" node as it does drops the content "body" of the request.
I have a device sending a data in XML format, have configured "http-in" node for a POST and when i send JSON, form-data, a file i get the data.
When i send XML data the "params", "body" is a empty.
Here is what I see, when I use Postman to simulate.
I can see all in headers section:
{"host":"example.com","user-agent":"PostmanRuntime/7.1.5","content-length":"945","accept":"*/*","accept-encoding":"gzip, deflate","cache-control":"no-cache","content-type":"application/xml","postman-token":"dd8b275a-caa2-4658-9e32-ac4cf4ea8d98","x-forwarded-for":"1.1.1.1","x-forwarded-host":"example.com","x-forwarded-port":"443","x-forwarded-proto":"https","x-forwarded-server":"c881bec96932","x-real-ip":"1.1.1.1"}
anyone would have an idea, what I need to change?
Thank you
the reason would be that Express does not have XML
middleware.
now to figure how to do
npm install express-xml-bodyparser --save
for express for http-in node.
What does msg.payload
contain?
Quick test shows msg.payload
contains the unparsed XML as a String; so you can pass that to through an XML node to get the parsed version.
If you really wanted to add extra middleware, then you can use httpNodeMiddleware
in your settings file to add additional custom middleware to the HTTP nodes.
awesome, that will do for me, after digging further as I originally used a device manual and did not check headers , or did not look close enough
the device is sending a POST request without a Content-Type
parameter. That is the reason for empty msg.payload
.
I have solved it in meanwhile using express js server and adding express bodyparser.raw()
to handle this type of request and Post parsed XML to the node-red http-in
.
will try to mod a settins.js
file as well,
Thank you