# 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:** 7\
**Page:** 2

<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:33pm UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/22 "2021-09-23T14:33:17Z")

</div>

You just need to add the url in the webapi "[https://ACCOUNT](https://ACCOUNT) SID:AUTH [TOKEN@api.twilio.com](mailto:TOKEN@api.twilio.com)/2010-04-01/Accounts/SERVICE ID/Messages.json

 ![Screenshot 2021-09-23 172626](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/6/a63f47167c81b68063b87d2fe79820cc7498c9c6.jpeg)

---

<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, 2:40pm UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/23 "2021-09-23T14:40:08Z")

</div>

Thank you @abdallask  
I gave all above recommendations and this confirms that my suggestions in the other post should be workable.

However, can I ask you to confirm that the `Header` in the `Web API` setup shows  
Content-Type= application/x-www-form-urlencoded

Many thanks in advance.

---

<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:51pm UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/24 "2021-09-23T14:51:13Z")

</div>

I don’t have any Header setup, it works without it I guess.  
maybe because of this it’s not stable? It works most of the time but not everytime!

---

<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, 2:52pm UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/25 "2021-09-23T14:52:50Z")

</div>

Many thanks for your confirmation.

If you don’t have Content-Type in the header it will default to `text/plain` which as you experienced will not be stable.

**[Edit]**  
Another thing I noted. You are checking the `status` to be 201. In fact all 200 range is good not only 201 specifically.

List of codes for API requests

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

---

<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 24, 2021, 3:52am UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/26 "2021-09-24T03:52:19Z")

</div>

Hi @abdallask and @muneer,

This is now my working Blocks.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/9/59247b66732c38ca1b04cf6f035385ea8f7b13b4.png)

I read an article about [postman.com](http://postman.com), I used the curl statement Twilio provided, put them each in their corresponding places. The most important thing is in the Authorization Tab, I selected Basic Auth and typed my $TWILIO\_ACCOUNT\_SID in the Username Entry and $TWILIO\_AUTH\_TOKEN in the Password Entry. After that, I opened the Headers Tab including the Hidden Auto-generated Headers, I saw the base64 encoded Authorization. This is in the form of **Basic set-of-random-characters** different from the $TWILIO\_ACCOUNT\_SID:$TWILIO\_AUTH\_TOKEN. This is what @muneer is referring about encrypted **$TWILIO\_ACCOUNT\_SID:$TWILIO\_AUTH\_TOKEN**. I copied that and placed it in my Headers in Thunkable along side with my current Content-Type:application/x-www-form-urlencoded

There is no need to use **%2B** or **%20** for the Body, From and To in the Body Block. It has a 201 status and the SMS is sent to the Phone Number stored in my variable. Phone number formats should follow the format below:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/0/40dd4ac0cd807c06b81dddbd6c84ed52b309fb16.png)

Thank you all.

---

<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 24, 2021, 4:11am UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/27 "2021-09-24T04:11:21Z")

</div>

So I concluded from above that you were getting 401 because the **set-of-random-characters** were not the correct one. Once generated by Postman and you used it in the app it worked.

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 12:19pm UTC](https://community.thunkable.com/t/web-api-post-function-for-twilio/1040399/28 "2024-11-08T12:19:26Z")

</div>

Closed on November 8, 2024, 12:19pm UTC



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