# 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:** 1

<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 19, 2023, 9:41pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/1 "2023-01-19T21:41:28Z")

</div>

Hello!  
I’m trying to get (Stablediffusionapi) to work using the Web API Feature but had no success…  
This is a photo of the blocks I’m using

- I’ve tried different blocks in the Header including ( Accept - engine-ID … etc )
- I’ve also tried different endpoints but have had no success
- everything is working as it should in Postman so i have no problem with my API whatsoever

I’m getting an error (NetworkError when attempting to fetch resource.) when trying to test the App on the web so I have exported the APP as APK but i got no error message when trying ( no response)

Does anyone know where could the problem be ?  
Thanks in advance 🙂

 ![333](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/2/d2c0e60e03e8398ebdb4219ce8c75f409733a415.png)

---

<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 19, 2023, 11:45pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/2 "2023-01-19T23:45:28Z")

</div>

if the call was ok (status=200), then the returned picture is from property “output” (see sample from response from [Text To Image - Stable Diffusion API](https://stablediffusionapi.com/docs/features/text-to-image))

---

<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 20, 2023, 4:33pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/3 "2023-01-20T16:33:29Z")

</div>

Thanks for your reply!  
So you mean i have an error in the last block?  
I have created an if-do block and said if the status = 200 then show the result like this  
But how can i add (output)  
Should I write it in the text block?

 ![Screenshot_20230120_173316](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/5/c5dbb430a9aacd0fe9f8574cb6519f0e40bc0ea7.png)

---

<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 20, 2023, 6:50pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/4 "2023-01-20T18:50:31Z")

</div>

Use ‘output’ as property name

 ![Screenshot_20230120-105442_Chrome](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/3/33be8bfd090ab7d567c944d08addad691de407f1.jpeg)

---

<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 20, 2023, 6:55pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/5 "2023-01-20T18:55:59Z")

</div>

i did that but didn’t work also ☹

---

<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 20, 2023, 7:20pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/6 "2023-01-20T19:20:47Z")

</div>

Can you try “output[1]” as the property. The returned object in ouput is an array.

---

<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 20, 2023, 7:36pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/7 "2023-01-20T19:36:34Z")

</div>

Nothing happens,  
I don’t get any error message or any result and the dashboard in stablediffusionapi didn’t register any Response or request  
and I’m pretty sure of everything including the API and url  
so frustrating…

---

<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 21, 2023, 6:41pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/8 "2023-01-21T18:41:48Z")

</div>

i got it to work - here’s my output.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/e/9e4009aef7afbcd498eab14109f43d6b44755058.jpeg)

i was down to 7 remaining calls when i got it to work (20 free calls per month).  
here are the blocks:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/7/87781c9ac31addc073c46c64e20e19d4412013da.png)  
(i was using textinput2- field at bottom - for debugging)

and here’s the project (you have to provide an apikey)  
[https://x.thunkable.com/copy/d016811384ade549eb4cb61154380a75](https://x.thunkable.com/copy/d016811384ade549eb4cb61154380a75)

---

<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 21, 2023, 6:49pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/9 "2023-01-21T18:49:34Z")

</div>

i know why it’s not working for you. you’re inside the if\_error block when you’re testing the status. if your call was successful, you’d never get inside your 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 21, 2023, 7:46pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/10 "2023-01-21T19:46:59Z")

</div>

Thanks for your help!!  
The error was actually because how I have the body, I had samples then negative prompt then height so when I tried your project I used the same textinput2- field at the bottom - for debugging and I got an error saying the height must be a number and sample must be a number so I knew I had something wrong in the body  
Thanks again for the fantastic help \<3

---

<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 21, 2023, 7:53pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/11 "2023-01-21T19:53:45Z")

</div>

glad to help!

---

<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 22, 2023, 2:27pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/12 "2023-01-22T14:27:44Z")

</div>

Is it possible to let the user download the result image or not ?

---

<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 22, 2023, 4:44pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/13 "2023-01-22T16:44:24Z")

</div>

Can you try the “outdir” paramter, use a value of “,” (dot) and see if ut saves it to Downloads. Otherwise you’ll have to do s creen capture, or send a query to stability ai.

---

<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 22, 2023, 5:34pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/14 "2023-01-22T17:34:19Z")

</div>

thanks for replying!  
After some work I found a way to do it and it worked 😍

---

<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 22, 2023, 6:13pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/15 "2023-01-22T18:13:15Z")

</div>

Are you going to share it?

---

<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 22, 2023, 7:05pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/16 "2023-01-22T19:05:25Z")

</div>

Yes sure,  
I’ve set the result to an App variable called result then used the resize image block when the user clicks on Download and I’ve used the upload file block with an open link block as well ( URL) so when the user clicks on download it uploads the result to URL and opens a link with the photo ready to download

---

<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 22, 2023, 10:48pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/17 "2023-01-22T22:48:08Z")

</div>

thanks for sharing!

---

<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, 5:17pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/18 "2023-01-23T17:17:45Z")

</div>

Another question if you don’t mind 🙂  
is there anything wrong with my If-do block?  
because it navigates to download page even if status is not 200  
I tried response and tried if not error also

 ![Screenshot_20230123_181458](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/2/724ae71b7c3100b1220254e8bede95cf393c6cfb.png)

---

<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:26pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/19 "2023-01-23T17:26:06Z")

</div>

The `status` block returns a text string. So you need to compare it to “200”. I usually just check for an error and don’t worry about the status but I’d try that if you need to check it.

---

<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, 5:34pm UTC](https://community.thunkable.com/t/problem-implementing-web-api-stablediffusionapi/2231354/20 "2023-01-23T17:34:36Z")

</div>

i tried that as well, if not error and if stats = text string (200) and in both cases it didn’t work

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