Web API Post function for Twilio

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?

1 Like

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.

1 Like

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

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

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.

1 Like
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" \


This is example from the Twilio API site


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.

1 Like

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

Than you!

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.

1 Like

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

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

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.

1 Like

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


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.


1 Like

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???

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.

1 Like

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

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.


1 Like

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 …

1 Like

Looking to see that here abdallask!

Thank you.