Problem implementing web API (Stablediffusionapi)

(Oops, accidentally edited this post which was asking you to try it with just the error block)

yes that’s the problem it works even if there is an error

Can you post a screenshot of the blocks where you’re checking for the error? And you’re saying that when an error is returned (set label’s text to [green error] block), it still runs the blocks in the else section? That shouldn’t be possible.

Even if there is an error it navigates to download page

Okay but how are you verifying that there is actually an error? I don’t see the green error block assigned to a label. It’s likely (and I had this happen with a different Stable Diffusion endpoint) that it’s returning a blank or null value but the API connection is in fact working successfully. So there is no error.

Please try setting a label’s text to the green error block just above the navigate block. And either remove the navigate block or add a wait block so you have enough time to see the error message. I would do the same with the response block. Assign it to a label’s text.

And then report back:

  1. What does the error block show?
  2. What does the response block show?

i’m verifying the error by using if not error block and then else …

BlockquoteIt’s likely (and I had this happen with a different Stable Diffusion endpoint) that it’s returning a blank or null value but the API connection is in fact working successfully. So there is no error.

Thanks for this information, I’ll try what you asked me to do and then report back here

1- Error label shows undefined
2- response label shows status error

Can you post a screenshot of the updated blocks?

The navigate to block works even if there is no error so I’ve created a 15 sec waiting time to see the error and response message

1- Error label shows undefined
2- response label shows a status error
Update :
tried with status block to a text label and it always return the value 200 even if there is no photo generated

“undefined” IS an error. It’s just not very helpful! So your if [error] block is correctly detecting an error and navigating to the Download Page. If you don’t want that to happen, you need to put the “working” blocks in the else section of the if [error] block.

Thanks for your reply i did that but it still navigates to the download page
Screenshot_20230124_181347

The problem is that (the error label is showing undefined in both cases when there is a photo and when not) so that’s why error is not working and the status is always showing 200 as well, so all we have here is response which is different

So when you get a valid response with a photo, the error block still has a value? Strange. I’ve never seen an API reply with a valid response and an error.

Exactly!
I’m getting undefined in both cases when there is a photo and when not
the same applies to status = 200 .

Are we still referring to the call to stable diffusion? If you recall. The response json includes a property called “status”. (Different from the green status block. Maybe you should check if it has a value of “success” to indicate a true successful action. (See snapshot from their web site that i posted early in the thread)

1 Like

Yes we’re still talking about stable diffusion call.

do you know how can I apply this json response status in thunkable ? because I’m only using the status from the call API block.

The same way you’re getting keyword/property “output” to get url of image. Do the same for property “status”.
Ie. If property “status” of json = “success” then…
image

3 Likes

Thank you I’ll try it tomorrow!

That makes a lot more sense. Thanks for clarifying.