Using Dynamic Variables in the API Connector

Hello Bubble Community,

I am attempting to use the bubble API connector and dynamic variables to pass unique user phone numbers to Twilio. I am not sure if it’s the JSON syntax that I placed into the body but I keep getting an error message when initializing. Images of the API connector and error message are below.

Thank you for your assistance in advance.

You’re missing a comma after the from value in your JSON. Try adding that and see if that works.

1 Like

I added the comma and it still wont initialize.

Delete the last comma in that.

{
  "Body": "<Body>",
  "From": "<From>",
  "To": "<To>"
}
1 Like

What’s the error message now?

1 Like

You need to add header
Content-type with value to application/json

1 Like

I added the header and I am still getting this error message.
There was an issue setting up your call.

Raw response for the API
Status code 400
{“code”: 21604, “message”: “A ‘To’ phone number is required.”, “more_info”: “The destination 'To' phone number is required to send an SMS | Twilio”, “status”: 400}

its the same

curl -X POST https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Messages.json \--data-urlencode "From=+15017122661" \--data-urlencode "Body=body" \--data-urlencode "To=+15558675310" \-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN

The call need to be sent as url parameter. So don’t use the content type I suggest
You should encode your “body json” this way

From=<from>&To=<To>&Body=<body>

It should work

2 Likes

And use this content type
Content-type
application/x-www-form-urlencoded
And be sure to use the correct phone format expected by twilio

1 Like

This is the error message

& this is the most recent screen shot of the api connector.

Content-type is the key and application/x-www-form-urlencoded is the value
also, you should just have the endpoint url in the POST url

https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Messages.json
(replace by your twilio accound SID)

1 Like

Should your body of the api call be in Json format? Your response body looks like a standard query string

Thank You!!! I love community of people who use bubble!

1 Like

@Jici I searched the Twilio API documentation and could not find the header that you told me to use. How did you know what to use for the header?

Quick input I found out that “content-type” should all be lowercase or the first letter should be capital on both words like “Content-Type”. Not sure if bubble ever fixed that bug.