HTTPPOST

Good time. Can you tell me how to transfer a file in an HTTP POST node in a request?

As usual, it will be a thousand times easier to answer your question if:

  1. Describe what you have already tried?
  2. Which of the things you tried did not work?
  3. What do you expect?

Screenshots and patch files are also very helpful.

if you are familiar how to form the request try that nuget: NuGet Gallery | VL.SimpleHTTP 1.2.1
seems to based on Hello from RestSharp | RestSharp
Preparing requests | RestSharp

http post.vl (9.9 KB)
I’ve tried this, but it doesn’t work. I need to transfer an image file to the server for processing.Everything works out with postman, but I can’t figure it out here.

I think you are initially setting up POST incorrectly, as everything related to multipart is hidden inside the library.

On the other hand, there is an experimental node for this. Have you tried it?

There is a serious suspicion that there is some bug in HTTPPost (Multipart). When using this node with ComfyUI, there is an exeception that drops out to the console (something about RandomBoundary). Similar code in Python works.

Mm, when uploading files like this there are things to consider, usually it takes files as arrays, also it often my ask to have a certain key on file like name: "file", filename: "file.png", do you have an api reference for this? And check for hidden pins…

this one works:

import requests

# Path to the file
image_path = r"C:\Input.jpg"

# URL ComfyUI
url = "http://127.0.0.1:8188/upload/image"

# Uploading as multipart/form-data
with open(image_path, "rb") as f:
    files = {
        "image": ("Input.jpg", f, "image/jpeg")
    }
    data = {
        "filename": "Input.jpg",   
        "type": "input",          
        "overwrite": "true"        
    }
    response = requests.post(url, files=files, data=data)

print("Status code:", response.status_code)
print("Response:", response.text)

I have found this bug and now I am looking for a way to solve it.

If very simply, it writes data to the void and in the end it gives out the void too. That is, where bytes should be written, a spread with zero size is written.

Yea, not sure what VL POST is using RestSharp? Or native c# one, both really perky on FormData. The most issues with it is a shape of object witch is hard to setup properly… also note that for some clients you need to set headers manually

@antokhio I kept wondering what was bothering me. That’s right! I could just do it via RestSharp!)

However, the bug in writing to streaming data is still real. Everything seems to be forming correctly otherwise. I just wish it would turn into bytes in the end.

upd: UploadMultiPart.vl (30.5 KB)