Help understanding http in output

Hello, new to node red and struggling to understanding how to to deal with the output of a webhook posting to an http in node

The payload comes out as a buffer which when converted to a string looks like:

Content-Type: application/json; charset=utf-8
Content-Disposition: form-data; name=data

{some JSON content}

Feeding this into a parse JSON node either gets me "Ignored non-object payload" if I do it directly, or "Unexpected number in JSON at position 1" if I convert the payload to a string first

Am I missing something obvious or does anyone have any advice?

Many thanks for any help

Where does the data come from, do you generate this yourself ?

Unfortunately not, I don't have control over the original output

Sure enough the JSON node won´t handle this kind of text. You will need to use a specialized parser for content-disposition response. There are a few on NPM, search for content-disposition. Probably it will be easier to use a NPM module instead of creating your own. Some reference.

If you tick the 'allow file upload' option in the HTTP In node, it should do all the parsing for you.

Thanks knolleary, that did the trick

The actual JSON payload itself is fairly standard - Just for my own (idiot's) understanding, is the content-disposition header in there effectively saying 'the content is something that needs to be downloaded', hence needing the file upload box ticked on the node? Is this pretty standard or a case of the headers being a bit wonky at the source in this particular case?

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