# Web API Post function for Twilio

**URL:** <https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399>\
**Category:** Questions about Thunkable X\
**Created:** [December 19, 2020, 2:11pm UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399 "2020-12-19T14:11:52Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![abdallask](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@abdallask](https://community.thunkable.com/u/abdallask)\
**Post date:** [December 19, 2020, 2:11pm UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/1 "2020-12-19T14:11:52Z")

</div>

I’ve been using the Web API component for a while now, I’ve been successfully sending post request to Twilio rest API with CURL. Yesterday the same blocks in Thunkable but getting the CURL error 400, according to the Web API status output I’m missing a parameter in the post body but I haven’t change anything. Could it be the Web API component?  
Is anyone else having problem with the Web API component?

---

<div class="post-metadata">

**Author:** ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)\
**Post date:** [December 19, 2020, 2:19pm UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/2 "2020-12-19T14:19:39Z")

</div>

First, is the project a legacy/production system or the beta drag and drop?

I’ve been working on a WebAPI today in the legacy/production and it works, but it isn’t using the body block.

This is a GUESS, but you might try changing the body block from a JSON string to an object. Previously, the body accepted text formatted as JSON. Try switching to to a JSON object and see if that changes anything. Again, just a guess on this one, but that is the kind of thing that changes regularly on Thunkable.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/d/bd1a58faf0aa8c9547f69a1b7cc6c0543c139c0a.png)

---

<div class="post-metadata">

**Author:** ![abdallask](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@abdallask](https://community.thunkable.com/u/abdallask)\
**Post date:** [December 19, 2020, 2:26pm UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/3 "2020-12-19T14:26:50Z")

</div>

It is a legacy project.  
I’ve never used generate JSON. it works by setting the body to text.  
Let me show you how … that the way it worked previously

 ![Screenshot 2020-12-19 162602](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/9/6999a2fefa282d3674eb556432cc76353d5c78f7.jpeg)

---

<div class="post-metadata">

**Author:** ![abdallask](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@abdallask](https://community.thunkable.com/u/abdallask)\
**Post date:** [December 19, 2020, 2:29pm UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/4 "2020-12-19T14:29:07Z")

</div>

Somehow now it can’t recognize the To field. in the return response it says missing the To parameter

---

<div class="post-metadata">

**Author:** ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)\
**Post date:** [December 19, 2020, 2:34pm UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/5 "2020-12-19T14:34:45Z")

</div>

The notation in the BODY block of WEB\_API2 looks a bit more like query parameters than body parameters. The way THUNKABLE assembed these properties together to send the request might have allowed this to work previously, but _fixings_ something might have broken your code.

It is hard to tell more without knowing the API service you are using.

---

<div class="post-metadata">

**Author:** ![abdallask](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@abdallask](https://community.thunkable.com/u/abdallask)\
**Post date:** [December 19, 2020, 3:04pm UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/6 "2020-12-19T15:04:43Z")

</div>

```auto
curl -X POST https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Messages.json \

--data-urlencode "Body=This is test?" \

--data-urlencode "From=+15017122661" \

--data-urlencode "To=+15558675310" \

-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN

```

This is example from the Twilio API site

---

<div class="post-metadata">

**Author:** ![gobassky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/gobassky/32/77019_2.png) [@gobassky](https://community.thunkable.com/u/gobassky)\
**Post date:** [December 25, 2020, 2:02am UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/8 "2020-12-25T02:02:29Z")

</div>

Hi

Me too. Took me a while to get my POST to work also. My issues were the content-type. Because the POST server accepts Url encoded string, I have to encode the body string into an URL encoded string with some characters replaced by %something… and then it works. Hope this helps.

---

<div class="post-metadata">

**Author:** ![abdallask](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@abdallask](https://community.thunkable.com/u/abdallask)\
**Post date:** [December 25, 2020, 2:35am UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/9 "2020-12-25T02:35:52Z")

</div>

Hi,  
what do you mean by URL encoded string?  
can you an example?

Than you!

---

<div class="post-metadata">

**Author:** ![gobassky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/gobassky/32/77019_2.png) [@gobassky](https://community.thunkable.com/u/gobassky)\
**Post date:** [December 25, 2020, 3:33am UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/10 "2020-12-25T03:33:52Z")

</div>

For example: an API string may contain characters outside ASCII set, URL encoding replaces unsafe ASCII characters with a “%” followed by two hexadecimal digits. URLs cannot contain spaces. URL encoding normally replaces a space with a plus (+) sign or with %20. Google URL encoding, there are a lot of free service to help code and decode.

---

<div class="post-metadata">

**Author:** ![abdallask](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@abdallask](https://community.thunkable.com/u/abdallask)\
**Post date:** [December 25, 2020, 3:50am UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/11 "2020-12-25T03:50:10Z")

</div>

But my POST body don’t have any space in it.

---

<div class="post-metadata">

**Author:** ![gobassky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/gobassky/32/77019_2.png) [@gobassky](https://community.thunkable.com/u/gobassky)\
**Post date:** [December 25, 2020, 4:00am UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/12 "2020-12-25T04:00:03Z")

</div>

Not only the space character. It is just an example.

---

<div class="post-metadata">

**Author:** ![abdallask](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@abdallask](https://community.thunkable.com/u/abdallask)\
**Post date:** [December 25, 2020, 6:59am UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/13 "2020-12-25T06:59:20Z")

</div>

I did figure it out thanks to you. I would never find out about this solution. You just helped me a lot and made my day …  
Thank you, really appreciate it.

---

<div class="post-metadata">

**Author:** ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)\
**Post date:** [December 25, 2020, 10:24am UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/14 "2020-12-25T10:24:02Z")

</div>

Could you post your final blocks so people in the future can learn from them?

---

<div class="post-metadata">

**Author:** ![arty3mm](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@arty3mm](https://community.thunkable.com/u/arty3mm)\
**Post date:** [September 23, 2021, 5:49am UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/15 "2021-09-23T05:49:13Z")

</div>

Hi abdallask,

Could you please post your solution here. Your Blocks, Headers, Query Parameters (if there’s any) and how did you incorporate the -u $TWILIO\_ACCOUNT\_SID:$TWILIO\_AUTH\_TOKEN.

I posted a new topic regarding this but haven’t had the right solution from the community.

Thanks.

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [September 23, 2021, 10:38am UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/16 "2021-09-23T10:38:01Z")

</div>

> [@arty3mm](#):
>
> $TWILIO\_ACCOUNT\_SID:$TWILIO\_AUTH\_TOKEN

This is part of your authentication and it is in the header as the “Bearer”. However, when I asked you to show your blocks, you repeated yourself. How do you want member of the community to help???

---

<div class="post-metadata">

**Author:** ![arty3mm](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@arty3mm](https://community.thunkable.com/u/arty3mm)\
**Post date:** [September 23, 2021, 1:45pm UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/17 "2021-09-23T13:45:45Z")

</div>

I didn’t use Blocks for my Headers.

All the Blocks used were posted in the other thread. This includes the URL, Body and the webAPI POST.

And I just found out this thread and abdallask found out the correct way to do it so I asked if the solution can be posted here.

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

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [September 23, 2021, 1:48pm UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/18 "2021-09-23T13:48:11Z")

</div>

See that the same request was given on December last year but not answered.

> [@Web API Post function for Twilio](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/14):
>
> Could you post your final blocks so people in the future can learn from them?

---

<div class="post-metadata">

**Author:** ![arty3mm](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@arty3mm](https://community.thunkable.com/u/arty3mm)\
**Post date:** [September 23, 2021, 1:57pm UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/19 "2021-09-23T13:57:38Z")

</div>

Yes, I saw that. I was hoping it could be answered this time.

I have been following your suggestions, and I thank you for that. But I still have errors.

Have you tried implementing this on your side? Have you had any errors? If none, then maybe, you can post your Blocks here.

Thanks.

---

<div class="post-metadata">

**Author:** ![abdallask](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@abdallask](https://community.thunkable.com/u/abdallask)\
**Post date:** [September 23, 2021, 2:15pm UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/20 "2021-09-23T14:15:42Z")

</div>

Hello,  
Well yes i made it work indeed but it is not perfect, it seems to work very fine most of the times but if you make a change to one thing it will break it.  
from what I learned if you do make it work, don’t do anything else …  
I will send a screenshot of how I make it work …

---

<div class="post-metadata">

**Author:** ![arty3mm](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@arty3mm](https://community.thunkable.com/u/arty3mm)\
**Post date:** [September 23, 2021, 2:17pm UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/21 "2021-09-23T14:17:06Z")

</div>

Looking to see that here abdallask!

Thank you.

[Next page](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399.md?page=2)
