HTTP POST payload empty (with code)

Hello
My name is Vitor and I'm a newbie :sweat_smile:

Well... I'm trying post an image(base64) but I'm doing something wrong. :persevere:

Can anybody help me?
:point_right: :point_left:

PS.: ( Yes, my english is terrible and I love emojis :heart:)

[{"id":"2c5d9a9a.f66d76","type":"debug","z":"52ff64e1.2eeebc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"statusCode","targetType":"msg","statusVal":"","statusType":"auto","x":580,"y":4100,"wires":[]},{"id":"7063876c.369298","type":"inject","z":"52ff64e1.2eeebc","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":90,"y":4040,"wires":[["cf4aa127.19db"]]},{"id":"cf4aa127.19db","type":"http request","z":"52ff64e1.2eeebc","name":"","method":"GET","ret":"bin","paytoqs":"ignore","url":"https://dummyimage.com/200x150/000/fff&text=test","tls":"","persist":false,"proxy":"","authType":"","x":230,"y":4040,"wires":[["fe2cfe82.0ce1d"]]},{"id":"fe2cfe82.0ce1d","type":"base64","z":"52ff64e1.2eeebc","name":"","action":"str","property":"payload","x":380,"y":4040,"wires":[["41666478.0efc7c"]]},{"id":"41666478.0efc7c","type":"function","z":"52ff64e1.2eeebc","name":"","func":"//var encoded = Buffer.from(msg.payload).toString(\"base64\");\n//var decoded = Buffer.from(msg.payload, \"base64\").toString();\n//msg.payload[0] = encoded;\n//msg.payload[0] = encoded;\n//msg.payload=msg.payload\n//msg.body=msg.payload\n//    'multipart': true\n\nmsg.headers = {\n//    'content-type': 'text/json',\n//    'content-type': 'application/x-www-form-urlencoded',\n//    'Content-Type':'multipart/form-data;boundary=\"\"',\n//     'Content-Type': 'text/plain; charset=\"ISO-8859-1\"', \n//     'Content-Type': 'text/plain;base64', \n//     'Content-Type': 'text/html', \n//     'Content-transfer-encoding': 'base64'\n    }\n//    msg.payload = \"\";\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":200,"y":4100,"wires":[["2367a688.225b3a","c13969e6.fb19a8"]]},{"id":"a6c3ae0f.4fa7c","type":"http in","z":"52ff64e1.2eeebc","name":"","url":"/files","method":"post","upload":true,"swaggerDoc":"","x":80,"y":4160,"wires":[["9a27df8c.73c74","14def71.1a47b09","332ab622.ceb2ca"]]},{"id":"fae2a83a.9340c8","type":"http response","z":"52ff64e1.2eeebc","name":"","statusCode":"","headers":{},"x":430,"y":4160,"wires":[]},{"id":"9a27df8c.73c74","type":"debug","z":"52ff64e1.2eeebc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":230,"y":4200,"wires":[]},{"id":"2367a688.225b3a","type":"http request","z":"52ff64e1.2eeebc","name":"http test","method":"POST","ret":"txt","paytoqs":"ignore","url":"http://localhost:1880/files","tls":"","persist":false,"proxy":"","authType":"","x":380,"y":4100,"wires":[["2c5d9a9a.f66d76"]]},{"id":"14def71.1a47b09","type":"change","z":"52ff64e1.2eeebc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"okay","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":260,"y":4160,"wires":[["fae2a83a.9340c8"]]},{"id":"332ab622.ceb2ca","type":"image","z":"52ff64e1.2eeebc","name":"","width":160,"data":"payload","dataType":"msg","thumbnail":true,"active":true,"pass":true,"outputs":1,"x":260,"y":4240,"wires":[[]]},{"id":"c13969e6.fb19a8","type":"image","z":"52ff64e1.2eeebc","name":"","width":160,"data":"payload","dataType":"msg","thumbnail":true,"active":true,"pass":true,"outputs":1,"x":600,"y":4140,"wires":[[]]}]

Thanks in advance!!!!!

After you base64 encode move the payload to msg.payload.data, or any name you wish. The http request node adds the payload object as a JSON when using post.

[{"id":"7063876c.369298","type":"inject","z":"c74669a0.6a34f8","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":130,"y":2160,"wires":[["cf4aa127.19db"]]},{"id":"cf4aa127.19db","type":"http request","z":"c74669a0.6a34f8","name":"","method":"GET","ret":"bin","paytoqs":"ignore","url":"https://dummyimage.com/200x150/000/fff&text=test","tls":"","persist":false,"proxy":"","authType":"","x":270,"y":2160,"wires":[["fe2cfe82.0ce1d"]]},{"id":"fe2cfe82.0ce1d","type":"base64","z":"c74669a0.6a34f8","name":"","action":"str","property":"payload","x":420,"y":2160,"wires":[["88a23af9.464c38"]]},{"id":"88a23af9.464c38","type":"change","z":"c74669a0.6a34f8","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.data","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":2160,"wires":[["2367a688.225b3a"]]},{"id":"2367a688.225b3a","type":"http request","z":"c74669a0.6a34f8","name":"http test","method":"POST","ret":"txt","paytoqs":"ignore","url":"http://localhost:1880/files","tls":"","persist":false,"proxy":"","authType":"","x":420,"y":2220,"wires":[["2c5d9a9a.f66d76"]]},{"id":"2c5d9a9a.f66d76","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"statusCode","targetType":"msg","statusVal":"","statusType":"auto","x":620,"y":2220,"wires":[]},{"id":"a6c3ae0f.4fa7c","type":"http in","z":"c74669a0.6a34f8","name":"","url":"/files","method":"post","upload":true,"swaggerDoc":"","x":120,"y":2280,"wires":[["14def71.1a47b09","9a27df8c.73c74"]]},{"id":"14def71.1a47b09","type":"change","z":"c74669a0.6a34f8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"okay","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":2280,"wires":[["fae2a83a.9340c8"]]},{"id":"9a27df8c.73c74","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":350,"y":2340,"wires":[]},{"id":"fae2a83a.9340c8","type":"http response","z":"c74669a0.6a34f8","name":"","statusCode":"","headers":{},"x":590,"y":2280,"wires":[]}]

Thanks!! Isnt empty but the image preview not work...

:thinking:

Have no idea what the image node is, as i do not have it installed. Does it accept a base64 encode data url.

Thank you very much Cid, now it works.

Does this always send as an object?

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