Messaging API Service always responds with HTTP 403

So I’ve been stuck on this for the past 4 hours, and I can’t seem to wrap my head around it. I’ve gone as far as to completely copying and pasting javascript code from a devforum post, and it still does not work.


Code in Studio (this ones probaly unimportant, see nodejs code below)

local MessagingManager = {}

local MessagingService = game:GetService("MessagingService")
local HttpService = game:GetService("HttpService")
local DataStoreService = game:GetService("DataStoreService")

function MessagingManager:Init()
	MessagingService:SubscribeAsync("GlobalModeration", function(message)
		print(message.Data)
	end)
end

return MessagingManager

NodeJS Code (the important one, which shows the error)

const axios = require('axios').default

module.exports.MessageSend = async function MessageSend(Message, Topic) {

    const response = await axios.post(
        `https://apis.roblox.com/messaging-service/v1/universes/4204279113/topics/${Topic}`,
        {
            'message': Message
        },
        {
            headers: {
                'x-api-key': 'the api key',
                'Content-Type': 'application/json'
            }
        }
    ).catch(err =>{
        console.log(err.response.status)
        if (err.response.status == 401) return console.log(`api key invalid, not authorized`)
        if (err.response.status == 403) return console.log(`denied, publish possibly not allowed on universe, not authorized`)
        if (err.response.status == 500) return console.log(`internal server error, not authorized`)
        if (err.response.status == 400){
            if (err.response.data == "requestMessage cannot be longer than 1024 characters. (Parameter 'requestMessage')") return console.log(`request message cannot be longer than 1024 characters, not authorized`)
            console.log(err.response.data)
        }
  })
    if (response){
        if (response.status == 200) return console.log(`200 OK`)
        if (response.status != 200) return console.log(`unknown error occured, not authorized`)
    }
}

If you perceived the NodeJS code above as similar, that is because I’ve copied it from the devforum post as an act of desperation.

Also, yes, HttpService and API Services are both enabled in the game.

Any help appreciated thanks.

2 Likes

I believe you had created this api from the Dashboard, But I also believe it has something to do with the Ip Address. I may not know much about it but I know if you go The security you can add some Ip Addresses.

If you put 0.0.0.0/0 it will allow all Ip adresses to access it, or you can put your own, but your ip address constantly changes so I would put 0.0.0.0/0

2 Likes

I’ve had simillar problem with it. Make sure you allowed your IP address and added your api key to your place

3 Likes

That was already there, I should’ve probaly informed you all about this in the post, whoops sorry.

Heres the rest of the API Key config

One interesting thing: I had to ask my friend (group owner) to add the game to the Access Permissions tab, because when I did it, saving changes wouldn’t work.

3 Likes

maybe check the UniverseId and make sure its not the PlaceId, or somethign else, also check the key too, I dont know what else to tell you.

4 Likes

I have checked them multiple times, they seem to be correct.

This might be a website bug.

3 Likes

Turns out simply deleting the API key and making a new one solves this issue. This could possibly be because for the second API key, the group holder created it, while the first one was made by the group owner but not the group holder.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.