Roblox Messaging Service Issue - Node.js Integration
1. What do you want to achieve?
I want to use the Roblox Messaging Service to send a request from a Node.js script to my Roblox game.
2. What is the issue?
When sending a request to Roblox using the correct API key and format, I receive the following error:
{ code: 7, message: 'Resources not authorized.', details: [] }
3. What solutions have you tried so far?
- Generated a new API key.
- Uploaded a new game and tested there.
- Reviewed documentation on the Roblox Creator Hub.
- Tried seeking help from AI.
Roblox Server Script
local MessagingService = game:GetService("MessagingService")
local function onMessageReceived(message)
print("Received message:")
print(message.Data)
end
print("Subscribed to topic: bot")
MessagingService:SubscribeAsync("bot", onMessageReceived)
Nodejs Script
const axios = require('axios');
const universeId = '128869192558631';
const apiKey = "";
const topic = 'bot';
const message = 'Hello, world!';
const url = `https://apis.roblox.com/cloud/v2/universes/${universeId}:publishMessage`;
const payload = {
topic: topic,
message: message
};
// Send the POST request
axios.post(url, payload, {
headers: {
'x-api-key': apiKey,
'Content-Type': 'application/json'
}
})
.then(response => {
console.log('Message published successfully:', response.data);
})
.catch(error => {
console.error('Failed to publish message:', error.response?.data || error.message);
});