How can I get this API Working?

Does anyone know how I can get this API working using Roblox Lua?

https://textbelt.com/

It basically sends a message to your phone, any message you POST to their website. But I cannot appear to get it to work.

No errors in the console, however, I do experience this return message from the website when I print it.
{“success”:false,“error”:“Missing phone number”}

I am currently trying:

local http = game:GetService(“HttpService”)
local url = “https://textbelt.com/text
local data = {
[‘phone’] = “myPhoneNumberGoesHere”,
[‘message’] = “Hello World!”,
[‘key’] = “textbelt”
}
http:PostAsync(url,data)

1 Like

Sorry, I wasn’t really that descriptive. I updated the post. I already tried that but still have issues.

Try encoding the data with http:JSONEncode() before you send it. I’m unsure if PostAsync encodes automatically, but it would be good to make sure.

3 Likes

Alright. I’ll try that.

1 Like

Thank you.

1 Like

If you’re ever having trouble hitting an API and you think your request might not look correct, you can send a request to one of https://httpbin.org/ ‘s endpoints and it will send back exactly what it received. It also has some other generic uses that help when creating a REST client that could be helpful when building out API code on Roblox.

2 Likes