RequestAsync not working?

So I am having this issue with RequestAsync. I Keep getting the error called HttpError: ConnectFail and I have no clue why this is happening. Please help! I really have no Idea on where to move on from here

local HttpService = game:GetService("HttpService")
 
local request = {}
request.Method = "POST"
request.Url = "http://URL/api/user/message/247964/"
request.Headers = {}
request.Headers["Content-Type"] = "application/x-www-form-urlencoded"
request.Headers["Token"] = "TOKEN"
request.Body = HttpService:JSONEncode({subject="roblox",body="studio"})
local response = HttpService:RequestAsync(request)
-- Inspect the response table
if response.Success then
	print("Status code: " .. response.StatusCode .. " " .. response.StatusMessage)
	print("Response body:\n" .. response.Body)
else
	print("The request failed: " .. response.StatusCode .. " " .. response.StatusMessage)
end

It looks like the request.Url is not valid.

 "http://URL/api/user/message/247964/"

Did you mean to change this to something else?

EDIT: Just realized you probably just redacted the url from the post.

1 Like

Assuming you’re POSTing to the right URL, do the requests ever reach the server?

Try using Postman to see if this is a Roblox problem or a problem with the URL/API itself.

1 Like

Yeah I actually was messing up on the Content-Type. I was sayings its a x-www-form-urlencoded but forgot I am sending it json so I just switched that haha :smiley: thanks for all the help.

1 Like