I asked about the Headers in my post above although I tried the following below :
Content-type: application/x-www-form-urlencoded
Authorization : Bearer $TWILIO_AUTH_TOKEN
Can you show the complete blocks of the body?
The Body block is also posted above. Please make suggestions if I am wrong . I reposted here below:
In your Post block you are only displaying error block but not status or response. What do they contain?
I have 400 in android and 401 in Apple device for their respective statuses.
Again, I need help because I don’t know what Headers, Query Parameters (if there are) and Objects should I initialize and put into my Blocks. I also need help with the -u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN too. Where to initialize them.
I only asked the questions after I went through your post and rewriting the same info will not help at all.
I need to know is this part of the Web API component setup or in a Headers code block. If it is part of the code, then show the image. You can of course redact the sensitive information. Is it an object or a text?
I asked for the complete and you provided exactly what was there. If it was sufficient I wouldn’t have asked for a better image.
What is available after the From=+44393…? Is there any other thing after the complete number? I’m asking about special characters used in formatting.
From the status of 400 the most possible cause is the format of your data. One common format used in API calls is to mimic the URL parameter format which means separating parameters by & sign. Try it and see if it solves the issue.
400 means the format of the information is wrong. This is connected with the information you supplied in the body section. Unfortunately, you decided not to show the complete block to see if you are following a specific format.
Right from the start, I admitted that I need help in putting the POST for this Twilio curl command. I don’t know how to put them into Thunkable Blocks, I don’t know what should I put as Headers or Query Parameters, or even the Body Parameters. The Blocks that I used are just my tries, and of course, because they are wrong, they are giving me errors, 400 and 401 statuses.
I’m sure, you are a Thunkable Expert, so, could you please show me your Thunkable Blocks for the following :
curl -X POST https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Messages.json
–data-urlencode “Body=Hi there”
–data-urlencode “From=+15017122661”
–data-urlencode “To=+15558675310”
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
Usually this goes into the body section but with the following format.
“Body=Hi%20there&From=+15017122661&To=+15558675310”
Use the same header that you used already.
For the first test, use all hard-coded in the body section. Once you see it working then you can use the variables to fill-in user data.
I read an article about 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 you are 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:
So I concluded from above that you were getting 401 because the set-of-random-characters were not the correct one. You had them generated by Postman and used it in your app and it worked.
OK, sorry for that, it must by a typo mistake (more correctly, a copy/paste mistake). Should you have pointed it out at that time it would have been corrected on the spot.
Now, that the issue is solved, enjoy the app running as expected.