# Where is my issue Http request push jpg

**URL:** <https://discourse.nodered.org/t/where-is-my-issue-http-request-push-jpg/76779>\
**Category:** General\
**Tags:** home-assistant\
**Created:** [21 March 2023 12:51 UTC](https://discourse.nodered.org/t/where-is-my-issue-http-request-push-jpg/76779 "2023-03-21T12:51:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrissica06](https://avatars.discourse-cdn.com/v4/letter/c/e0b2c6/32.png) [@chrissica06](https://discourse.nodered.org/u/chrissica06)\
**Post date:** [21 March 2023 12:51 UTC](https://discourse.nodered.org/t/where-is-my-issue-http-request-push-jpg/76779/1 "2023-03-21T12:51:07Z")

</div>

I am currently using Node-red in HA. I am attempting to push a JPG to Codeproject AI local server to get an OCR response back. I am getting responses back from the server, but I don't think it's getting the jpg data. As it always errors out in 6ms or less. My code is below. I can't figure out how to past it correctly. There is no \</\> button. Where am I going wrong?

```auto
[{"id":"fdf45dde0884a088","type":"inject","z":"4f64858a3d766e69","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":110,"y":600,"wires":[["6ab53aa60a5a28ac"]]},{"id":"25bd7939565752ad","type":"debug","z":"4f64858a3d766e69","name":"debug 15","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":640,"y":480,"wires":[]},{"id":"0a5e31bf976b3eac","type":"http request","z":"4f64858a3d766e69","name":"","method":"POST","ret":"obj","paytoqs":"body","url":"http://10.146.1.30:32168/v1/image/ocr","tls":"","persist":true,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"Content-Type","keyValue":"","valueType":"image/jpeg","valueValue":""}],"x":490,"y":480,"wires":[["25bd7939565752ad"]]},{"id":"6ab53aa60a5a28ac","type":"file in","z":"4f64858a3d766e69","name":"","filename":"/config/save_data/test1.jpg","filenameType":"str","format":"","chunk":false,"sendError":false,"encoding":"hex","allProps":false,"x":240,"y":480,"wires":[["0a5e31bf976b3eac"]]}]

```

The code below is from the Codepoject AI web site and works if i load it on a web browser.

```auto
<html>
<body>
Detect the scene in this file: <input id="image" type="file" />
<input type="button" value="Detect Scene" onclick="detectScene(image)" />

<script>
function detectScene(fileChooser) {
    var formData = new FormData();
    formData.append('image', fileChooser.files[0]);

    fetch('http://localhost:32168/v1/image/ocr', {
        method: "POST",
        body: formData
    })
    .then(response => {
        if (response.ok) response.json().then(data => {
            console.log(`Scene is ${data.label}, ${data.confidence} confidence`)
        });
    });
}
</script>
</body>
</html>

```

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [21 March 2023 13:08 UTC](https://discourse.nodered.org/t/where-is-my-issue-http-request-push-jpg/76779/2 "2023-03-21T13:08:15Z")

</div>

Hi @chrissica06 - welcome to the forums.

The html you have supplied, is a mulit-part form.  
Your flow is just sending a blob of data - not a multi-part form

Try the below, I have:

- Set the content type to `multipart/form-data`
- Constructed a a payload with the "form data"

```auto
[{"id":"fdf45dde0884a088","type":"inject","z":"c422701e0fbc1756","name":"","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":280,"y":165,"wires":[["6ab53aa60a5a28ac"]]},{"id":"0a5e31bf976b3eac","type":"http request","z":"c422701e0fbc1756","name":"","method":"POST","ret":"obj","paytoqs":"body","url":"http://10.146.1.30:32168/v1/image/ocr","tls":"","persist":true,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[{"keyType":"other","keyValue":"Content-Type","valueType":"other","valueValue":"multipart/form-data"}],"credentials":{},"x":920,"y":270,"wires":[[]]},{"id":"6ab53aa60a5a28ac","type":"file in","z":"c422701e0fbc1756","name":"","filename":"/config/save_data/test1.jpg","filenameType":"str","format":"","chunk":false,"sendError":false,"encoding":"hex","allProps":false,"x":405,"y":270,"wires":[["d77729fba8b0d15a"]]},{"id":"d77729fba8b0d15a","type":"function","z":"c422701e0fbc1756","name":"Format Form Data","func":"return {\n payload: {\n image: {\n value: msg.payload,\n options: {\n filename: 'test1.jpg'\n }\n }\n }\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":690,"y":270,"wires":[["0a5e31bf976b3eac"]]}]

```

---

<div class="post-metadata">

**Author:** ![chrissica06](https://avatars.discourse-cdn.com/v4/letter/c/e0b2c6/32.png) [@chrissica06](https://discourse.nodered.org/u/chrissica06)\
**Post date:** [21 March 2023 13:11 UTC](https://discourse.nodered.org/t/where-is-my-issue-http-request-push-jpg/76779/3 "2023-03-21T13:11:12Z")

</div>

WOW!!! Thank you! I am still learning and that worked the first time out.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [4 April 2023 13:11 UTC](https://discourse.nodered.org/t/where-is-my-issue-http-request-push-jpg/76779/4 "2023-04-04T13:11:44Z")

</div>

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