# Problem implementing web API (Stablediffusionapi)

**URL:** <https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354>\
**Category:** Questions about Thunkable X\
**Tags:** webapi, json\
**Created:** [January 19, 2023, 9:41pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354 "2023-01-19T21:41:28Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 23, 2023, 5:44pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/21 "2023-01-23T17:44:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![venus99](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/venus99/32/146306_2.png) [@venus99](https://community.thunkable.com/u/venus99)\
**Post date:** [January 23, 2023, 6:13pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/22 "2023-01-23T18:13:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 23, 2023, 6:23pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/23 "2023-01-23T18:23:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![venus99](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/venus99/32/146306_2.png) [@venus99](https://community.thunkable.com/u/venus99)\
**Post date:** [January 23, 2023, 6:43pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/24 "2023-01-23T18:43:06Z")

</div>

![Screenshot_20230123_194113](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/9/e94683b8ed4ea1bab275039d5f179edbf5115eed.png)

Even if there is an error it navigates to download page

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 23, 2023, 7:01pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/25 "2023-01-23T19:01:51Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![venus99](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/venus99/32/146306_2.png) [@venus99](https://community.thunkable.com/u/venus99)\
**Post date:** [January 23, 2023, 8:03pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/26 "2023-01-23T20:03:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![venus99](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/venus99/32/146306_2.png) [@venus99](https://community.thunkable.com/u/venus99)\
**Post date:** [January 23, 2023, 8:32pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/27 "2023-01-23T20:32:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 23, 2023, 10:05pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/28 "2023-01-23T22:05:04Z")

</div>

Can you post a screenshot of the updated blocks?

---

<div class="post-metadata">

**Author:** ![venus99](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/venus99/32/146306_2.png) [@venus99](https://community.thunkable.com/u/venus99)\
**Post date:** [January 24, 2023, 3:36pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/29 "2023-01-24T15:36:37Z")

</div>

![Screenshot_20230124_163601](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/c/9ceaea82a5f8a3ef69fbebf7d7a1dc62119c5b6e.png)

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

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 24, 2023, 5:03pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/30 "2023-01-24T17:03:44Z")

</div>

“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.

---

<div class="post-metadata">

**Author:** ![venus99](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/venus99/32/146306_2.png) [@venus99](https://community.thunkable.com/u/venus99)\
**Post date:** [January 24, 2023, 5:14pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/31 "2023-01-24T17:14:36Z")

</div>

Thanks for your reply i did that but it still navigates to the download page  
 ![Screenshot_20230124_181347](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/4/b453ca9e06b7e6f43961dba345bde1bb9b5672f4.png)

---

<div class="post-metadata">

**Author:** ![venus99](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/venus99/32/146306_2.png) [@venus99](https://community.thunkable.com/u/venus99)\
**Post date:** [January 24, 2023, 5:52pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/32 "2023-01-24T17:52:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 24, 2023, 7:30pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/33 "2023-01-24T19:30:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![venus99](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/venus99/32/146306_2.png) [@venus99](https://community.thunkable.com/u/venus99)\
**Post date:** [January 24, 2023, 8:20pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/34 "2023-01-24T20:20:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)\
**Post date:** [January 24, 2023, 8:29pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/35 "2023-01-24T20:29:08Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![venus99](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/venus99/32/146306_2.png) [@venus99](https://community.thunkable.com/u/venus99)\
**Post date:** [January 24, 2023, 8:35pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/36 "2023-01-24T20:35:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![manyone](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@manyone](https://community.thunkable.com/u/manyone)\
**Post date:** [January 24, 2023, 8:47pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/37 "2023-01-24T20:47:49Z")

</div>

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](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/d/4d1e834852c395496a0518758733228cdfe5f6fc.png)

---

<div class="post-metadata">

**Author:** ![venus99](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/venus99/32/146306_2.png) [@venus99](https://community.thunkable.com/u/venus99)\
**Post date:** [January 24, 2023, 8:56pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/38 "2023-01-24T20:56:53Z")

</div>

Thank you I’ll try it tomorrow!

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [January 24, 2023, 8:59pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/39 "2023-01-24T20:59:24Z")

</div>

That makes a lot more sense. Thanks for clarifying.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [April 24, 2023, 8:59pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/40 "2023-04-24T20:59:31Z")

</div>

Closed on April 24, 2023, 8:59pm UTC

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

[Previous page](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354.md?page=1)
