Hi all,
I desperately need help formatting a POST command. I've searched, but obviously not well, or I'd not be posting. I've lost a day to this, and I'm beating my head against the wall.
I'm trying to send an image to a Codeproject.ai-server, so it'll tell me what's in the pic. To connect with the server, I am using the HTTP POST command as described in the Codeproject API.
I get a jpg from a camera node; it does arrive, I can see it on my dashboard2. I wrap it in the required headers using a function node. Then I POST it.
The flow below does actually work, but the error that I'm receiving makes it clear that no image data arrived. As far as I can figure, therefore, I am somehow screwing up the formatting of the POST command. It has to be.
This is my flow:
[{"id":"eeaca59f759000ea","type":"inject","z":"8f99f3189f7e4f1d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":370,"y":240,"wires":[["442e2916c631ddc9"]]},{"id":"652ee96c8ed4c785","type":"ui-template","z":"8f99f3189f7e4f1d","group":"47ac84fa59116547","page":"","ui":"","name":"","order":2,"width":0,"height":0,"head":"","format":"<img :src=\"msg.payload\">","storeOutMessages":true,"passthru":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":780,"y":320,"wires":[[]]},{"id":"2f16ff9a923d4752","type":"debug","z":"8f99f3189f7e4f1d","name":"yAyI!","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1070,"y":240,"wires":[]},{"id":"b37f4dafdf04e74e","type":"function","z":"8f99f3189f7e4f1d","name":"function 26","func":"const thisimage = msg.payload;\n\nmsg = {\n headers: {\n 'content-type': 'multipart/form-data',\n },\n payload: {\n 'image': {\n 'value': thisimage,\n 'options': {\n 'filename': 'snapshot.jpg'\n }\n },\n 'min_confidence': 0.0\n }\n};\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":730,"y":240,"wires":[["3caba20b723cc336"]]},{"id":"3caba20b723cc336","type":"http request","z":"8f99f3189f7e4f1d","name":"","method":"POST","ret":"obj","paytoqs":"body","url":"http://server:32168/v1/vision/custom/ipcam-general","tls":"","persist":true,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":910,"y":240,"wires":[["2f16ff9a923d4752"]]},{"id":"442e2916c631ddc9","type":"hikvisionUltimatePicture","z":"8f99f3189f7e4f1d","name":"Room","topic":"","server":"bd732490a1f706cc","channelID":"8","rotateimage":"0","heightimage":"480","widthimage":"576","qualityimage":"100","cropimage":"","textoverlay":"","textoverlayXY":"0,0","textoverlayWH":"0,0","textoverlayFont":"FONT_SANS_32_WHITE","urlImageCurrentIndex":0,"x":510,"y":240,"wires":[["b37f4dafdf04e74e","652ee96c8ed4c785"],[]]},{"id":"47ac84fa59116547","type":"ui-group","name":"Image","page":"f59a4ca419fb842f","width":"6","height":"1","order":-1,"showTitle":true,"className":"","visible":"true","disabled":"false"},{"id":"bd732490a1f706cc","type":"Hikvision-config","host":"0.0.0.0","port":"80","name":"Server","authentication":"digest","protocol":"http","heartbeattimerdisconnectionlimit":"2","deviceinfo":"[object Object]","debuglevel":"no"},{"id":"f59a4ca419fb842f","type":"ui-page","name":"Motion tests","ui":"cf9dc2ba60d1396c","path":"/page3","icon":"home","layout":"grid","theme":"7ba40ffa60b22682","order":3,"className":"","visible":true,"disabled":"false"},{"id":"cf9dc2ba60d1396c","type":"ui-base","name":"My Dashboard","path":"/dashboard","includeClientData":true,"acceptsClientConfig":["ui-notification","ui-control"],"showPathInSidebar":true,"showPageTitle":true,"navigationStyle":"default","titleBarStyle":"default"},{"id":"7ba40ffa60b22682","type":"ui-theme","name":"Default Theme","colors":{"surface":"#ffffff","primary":"#0080ff","bgPage":"#eeeeee","groupBg":"#ffffff","groupOutline":"#cccccc"},"sizes":{"pagePadding":"12px","groupGap":"12px","groupBorderRadius":"4px","widgetGap":"12px"}}]
This is an example of the error:
`
{"headers":{"content-length":"328","content-type":"application/json","date":"Thu, 15 Aug 2024 14:28:49 GMT","server":"Kestrel","x-node-red-request-node":"07589556"},"payload":{"error":"Yolo returned null.","inferenceMs":0,"processMs":0,"analysisRoundTripMs":3,"success":false,"moduleName":"Object Detection (YOLOv5 .NET)","moduleId":"ObjectDetectionYOLOv5Net","command":"custom","requestId":"99ae0ae1-47c7-4c09-8240-723354a1c6d4","processedBy":"localhost","timestampUTC":"Thu, 15 Aug 2024 14:28:49 GMT"},"_msgid":"107d1105103317fe","statusCode":200,"responseUrl":"http://server:32168/v1/vision/custom/ipcam-general","redirectList":[],"retry":0}
Please, for the love of whatever entity you please, help. I am a broken human being.