Send XML with HTTP Request

I tried to send an XML message in the body of a HTTP Post Request.

I used the HTTP Request node for that with the body set:
image

I got this error:

I looked into the code and it tries to parse the string to a json object.

Is it correct that the current http request node can send only, files, webforms and json bodies?

If so, I would try to add the feature to send plain string with the http-request node.

Yes, that is true. That is right now sadly not possible.

The reason for that is that it currently always does a JSON.parse in line 561. It would probably need a “useRawData” option like the MoveBinaryData-Node. Additionally, would it be needed to define a custom content-type, to set it in this case to “application/xml”. Any help there would be very appreciated!

I opened a PR:
https://github.com/n8n-io/n8n/pull/102

While testing I noticed that the “Webhook Node” cannot handle non-json bodies.
I first created a “webhook”-workflow as recipient-bin for testing. I was never able to get the body.
I compared the requestOptions 1:1 to request-promise documentation and couldn’t see a difference.

So I sent it against one of the webhook-sites (requestbin etc.). There it worked just fine.

While I’m at it, I tried to extend the webhook-node to accept xml bodies, but I noticed that the parsing happens very deep in the core code of n8n.io. So I stopped.

Anyway, have a look at the extension to at least send raw-strings.

Thanks a lot your PR got merged and released with [email protected]

Yes, you are probably right that the webhook has issues with none JSON data. I have to look into that once I find some time.

quansenB made it now possible to also send XML data to n8n webhooks with this pull-request: Xml body parser webhooks by quansenB · Pull Request #150 · n8n-io/n8n · GitHub

It got released with [email protected]