Hello everyone,
I have to dialog with an API who will give me a "score" for each picture I send for deep learning vision.
So I'm trying to send pictures to the POST API but as far, i couldn't succeed.
The http request node seems to be well configured as I receive this kind of errors :
"{"detail":[{"loc":["body","file"],"msg":"Expected UploadFile, received: <class str'>","type":"value_error"}]}"
I think that I have a format error in my code but I can't figured out with it.
I also tried to transform my picture to a buffer array but even like that I couldn't succeed.
Please help me !
Here is the flow I made :
(For security reasons, I had to remove URL / TLS / Authentication token and proxy from the http request node)
[{"id":"ebd94d8a.3961b","type":"inject","z":"307bb120.7c02ce","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":900,"wires":[["d291267.73832d8"]]},{"id":"af5063f4.a57ea","type":"file-buffer","z":"307bb120.7c02ce","name":"","mode":"asStream","x":320,"y":980,"wires":[["27edfe17.6e4842","df6e18cef8ae507d"]]},{"id":"d291267.73832d8","type":"function","z":"307bb120.7c02ce","name":"Filename","func":"msg.payload = 'C:\\\\PicturesCobot\\\\Cobot00002.JPG';\nmsg.filename = 'C:\\\\PicturesCobot\\\\Cobot00002.JPG';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":170,"y":980,"wires":[["af5063f4.a57ea"]]},{"id":"27edfe17.6e4842","type":"debug","z":"307bb120.7c02ce","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":470,"y":940,"wires":[]},{"id":"cfc9bd999a61915a","type":"http request","z":"307bb120.7c02ce","name":"","method":"POST","ret":"txt","paytoqs":"query","url":"https://","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":690,"y":980,"wires":[["1912b45bd188dc45"]]},{"id":"1912b45bd188dc45","type":"debug","z":"307bb120.7c02ce","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":830,"y":940,"wires":[]},{"id":"df6e18cef8ae507d","type":"function","z":"307bb120.7c02ce","name":"Body + Headers","func":"var fileStream = msg.payload;//msg.file;//msg.filename;\n\nmsg.payload = {\n \"file\": fileStream,\n \"type\":\"image/jpg\",\n \"submission_id\":\"1305197593\"\n };\nmsg.headers = {\n 'content-type': 'multipart/form-data'\n};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":980,"wires":[["cfc9bd999a61915a","08ae3595ebae19f0"]]},{"id":"08ae3595ebae19f0","type":"debug","z":"307bb120.7c02ce","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":670,"y":940,"wires":[]}]
Regards