I run this command and it works well
curl -X POST https://studio.twilio.com/v1/Flows/FWc5598133xxxxxxxxxxx9e724dee0c/Executions \
–data-urlencode “To=+1954xxxxx5” \
–data-urlencode “From=+17862xxxxxx” \
-u “AC9xxxxxxxxxxxx9075dd5:c68d7bc01xxxxxxxxx9aaa7598”
But I have tried different ways in Losant http calls and I can’t do it.
Somebody already communicate successful with Twilio API ?
I was able to get it working using the following configuration in an HTTP Node, where the string templates are referencing values on your workflow’s payload. -
Request Method:
POST
URL Template:
https://studio.twilio.com/v1/Flows/{{data.FlowSid}}/Executions
Body Template:
From={{encodeURIComponent data.From}}&To={{encodeURIComponent data.To}}&Parameters={{encodeURIComponent data.Parameters}}
Headers:
Content-Type = application/x-www-form-urlencoded
Authorization Type:
Basic
Username:
{{data.AccountSid}}
Password:
{{data.AuthToken}}
1 Like
Thanks a lot!. It worked. My problem was in the body template
To reopen an old thread…but I’m struggling with this currently.
Maybe the HTTP node has changed since this was published in '18 ?
Stewart
The HTTP Node has indeed changed quite a bit in the past 3.5 years, especially the areas around building a request. If you can tell me specifically what request you are trying to make, I may be able to point you in the right direction.
I’m trying to make API call for a Twilio voice call using HTTP post
If I use your original post in a online API tool and add the twiml for the voice part it works for me.
But I can not get it to work in the Losant HTTP node.
Can you attach the workflow as you have it so far? Make sure to redact any credentials such as your Twilio token and the phone numbers if they’re entered directly into the HTTP Node. A good way to do that is to store them as workflow globals and then export the workflow to a file without the globals included.
Thanks. Let me look into this a bit and I’ll get back to you.
So I’m seeing a number of issues here, and for reference, I am comparing what you have in your workflow to Twilio’s documentation on making outbound calls. Your general HTTP Node setup is fine; it’s just these little errors …
This needs to be an https URL; using http seems to just return the account’s list of previous calls.
These should be “To” and “From”, not “to” and “from” (note the capitalization).
I couldn’t find it documented anywhere that you could pass TwiML inline in the request; instead, what I’ve found is you need to pass a “Url” parameter (again, note the capitalization) pointing to a spot where Twilio can pull the instructions for how to handle the call, in TwiML format.
It’s not hurting anything to have this header here, but it is not necessary. By virtue of choosing “application/x-www-form-urlencoded” as your “Body Type”, this header is being added to your request automatically by Losant.
Dylan
Thanks for the reply.
Changing the Url to https in the HTTP node gives me a 400 error
Using the online API tool you can pass the twiml instructions
This example works
There is no difference using https vs http using the API tool
A 400 response code, but what is in the body of the response? What is the underlying error?
21205
“Url parameter is required.”
“Error 21205 | Twilio”
400
Well there you go. Like I said, I didn’t see any documentation stating that you could pass “Twiml” as a parameter in the request. Try passing Url=http://demo.twilio.com/docs/voice.xml
in place of that.
If I’m reading that right, you put http://demo.twilio.com/docs/voice.xml
in as the URL to request in the HTTP Node. Instead, you should be making the request as you did before and putting that URL in as a parameter, alongside your “From” and “To” parameters, as part of the request. Key is “Url”, value is “http://demo.twilio.com/docs/voice.xml”
oops !
tried that , no sucess
Your request URI still needs to be switched to https.
You’re getting a 200 status code, and probably a list of calls made from this account in the response as I was before I made the switch to https in my testing.
Dylan,
The URI did work but only for the demo voice test.
Https works with /xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Calls.json
So deleted Uri…
I had to change “twiml” to Twiml ( just like To & From).
The Twiml content doesn’t need quotation marks like I was using so:
Name Template = Twiml
Vale Template = Ahoy, World!
works !
Thank you
Stewart
Ah, so passing the Twiml as an argument does work! That made me dig a little deeper and I found the full API reference for placing a call, in case you need it for your future Twilio adventures.
Glad to hear we got it worked out. Let us know if you have any other questions.