HttpService: HTTP 403 (Forbidden) Error

Alright! thank you so much man! let me try again.

You could try using the pastebin API to retrieve the post. You can’t just do the URL to the post, because Roblox isn’t logged in to your pastebin account, and your pastebin isn’t public or unlisted. It might be more reliable using an API key as it could be that you’re running into a limit of some sort.

You can read about the API here:

Edit: Updated - I thought the bin was not public.

Speaking of 403 errors i was trying to reply and got a 403 error.

Anyway, here is a working example. I still think you should use another solution like MessagingService though:

local HttpService = game:GetService("HttpService")

local URL = "https://pastebin.com/raw/Ber30YMY"

while true do
	local success, result = pcall(HttpService.GetAsync, HttpService, URL) --Always use pcall if there is a possibility of an error
	
	if success then
		--It worked, result is going to be the data of the site
		print(result)
	else
		warn("Error caught: " .. result) --Since something went wrong, result will instead contain information about the error
	end
	
	task.wait(7.5) --Don't spam requests, it will rate limit you within seconds.
end

But it is public.
image

Also if that’s the problem why did it work this morning? (everything was working this morning)

I got the same error a few minutes ago too. Let me try your code.

You really should be using MessagingService instead if you want real-time updates. All you have to do to send and receive announcements is this:

local MessagingService = game:GetService("MessagingService")

MessagingService:SubscribeAsync("Announcements", function(message)
	--(Assuming message.Data is just a string)
	print("Got an announcement:", message.Data)
end)

MessagingService:PublishAsync("Announcements", "This will be sent to **all** servers!")
--(Keep in mind you should wrap publishasync in a pcall too, it might fail)

It is not only simpler, but faster and better (and probably more reliable) than writing your own hacks and http requests to do something that is already implemented.

(it literally exists for this very reason)

if i want to make live updates, what should i use?

Live updates as in, they happen everywhere right away? If so, then MessagingService.

(If you want the announcement to stay even in new servers, you can just save them using DataStoreService.)

I got this after putting the code.
image

local HttpService = game:GetService("HttpService")

local URL = "the url is giving me the same error here in dev fourm"

local Announcement = game:GetService("ReplicatedStorage").ANNOUNCEMENT

while true do
	local success, result = pcall(HttpService.GetAsync, HttpService, URL) --Always use pcall if there is a possibility of an error

	if success then
		Announcement.Value = result
		print(result)
	else
		warn("Error caught: " .. result) --Since something went wrong, result will instead contain information about the error
	end

	task.wait(7.5) --Don't spam requests, it will rate limit you within seconds.
end

How can i save them using DataStoreService?

This is only visible on your side. When i run the code it runs just fine and retrieves the data.

So it’s the problem just in my game?

Here is the Roblox developer hub article about data stores, i suggest reading it.

If you have any issues getting something to work with data stores feel free to PM me and i will see what i can do. (Assuming you are going to use data stores)

Alright thank you! Returning to the main topic, it’s the problem just in my game?

Assuming this is being tested in studio, i can think of one possibility. When in studio, http requests are made from your pc, not Roblox servers.

Are you able to open the pastebin url directly?

Nevermind, i figured it out. I don’t think you have HttpEnabled, if you are in a published game then check your game settings.

If it is not a published game, and you haven’t already done this, then this is why it isn’t working. It never struck me that 403 errors come up if you also have http requests disabled.

Run this in the command bar and try running the code again:

game:GetService("HttpService").HttpEnabled = true

I can, but it’s weird… everything was fine this morning, it was working IN studio.

Actually, i have it enabled. it is published tho.
image

Thought i had it there honestly. Alright can you run this code then show the console output?

local HttpService = game:GetService("HttpService")

local function request()
	local response = HttpService:RequestAsync(
		{
			Url = "https://pastebin.com/raw/Ber30YMY",  -- This website helps debug HTTP requests
			Method = "GET",
		}
	)

	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
end

local success, message = pcall(request)

if not success then
	print("Http Request failed:", message)
end

Alright, let me test it, i’ll tell you what happens in a few minutes.

1 Like