ComfyUI icon indicating copy to clipboard operation
ComfyUI copied to clipboard

You help with the API, error at the basic_api_example.py

Open zephirusgit opened this issue 2 years ago • 5 comments

Hello, a query, I was looking at the file of basic_api_example.py But it gives me a "(error)" . Traceback (Most Recent Call Last): File "c: \ ia \ comfyu 3 \ comfyui_windows_portable \ comfyui \ script_examples \ basic_api_example.py", line 118, in Queue_prompt (prompt) File "c: \ ia \ comfyu 3 \ comfyui_windows_portable \ comfyui \ script_examples \ basic_api_example.py", line 107, in queue_prompt REQUEST.URLOPEN (REQ) File "URLLIB \ REQUEST.PY", LINE 216, IN URLOPEN File "URLLIB \ REQUEST.PY", LINE 525, IN Open File "URLLIB \ REQUEST.PY", LINE 634, IN HTTP_RES File "URLLIB \ REQUEST.PY", LINE 563, IN ERROR File "URLLIB \ REQUEST.PY", LINE 496, IN _CALL_CHAIN File "URLLIB \ REQUEST.PY", LINE 643, IN HTTP_ERROR_DEFAULT URLLIB.ERROR.HTTPERROR: HTTP ERROR 400: BAD REQUEST

I was thinking of doing some things automatically, How to launch a work previously done and saved in the .json file and I see that in the example of the API the internal is masomenes, but the example of API does not work, I guess I evolve a lot from the last version, I have added the command -they are and have also tried to put the local IP to see if it worked but either.

Now, as I have different versions of Comfyui, for example I wanted to launch some things to each other to another, (for example where the reactor works for me)

Is there a way to do something like that? Does anyone understand why the API fails? Or can you think of how to send him. Json and what generates it? (I imagine the road there is the API) greetings and thanks.

Theme separate (Does anyone know how to fix the reactor for the new version?)

zephirusgit avatar Dec 04 '23 08:12 zephirusgit

Hi, I'm having the same issue. Did you solve it?

Pepper2020 avatar Apr 10 '24 18:04 Pepper2020

Hi, I'm having the same issue. Did you solve it?

I got it fixed by correcting a typo anyways...

Pepper2020 avatar Apr 10 '24 19:04 Pepper2020

I got it fixed by correcting a typo anyways...

any details, thx

aiXia121 avatar Apr 28 '24 12:04 aiXia121

Try using code like this

def queue_prompt(prompt): # p = {"prompt": prompt} # data = json.dumps(p).encode('utf-8') # req = request.Request("http://127.0.0.1:8188//prompt", data=data) # request.urlopen(req) response = requests.post("http://127.0.0.1:8188/prompt", json={"prompt": prompt}) print(response.status_code, response.text)

jinian2020 avatar Aug 14 '24 05:08 jinian2020

response = requests.post("http://127.0.0.1:8188/prompt", json={"prompt": prompt}) print(response.status_code, response.text)

seems work to me.

bobby20180331 avatar Aug 23 '24 13:08 bobby20180331