Uploading a .rbxm to Roblox

Hi all, for the past few weeks I’ve been trying to create a script that can upload a .rbxm file to Roblox over the endpoint https://data.roblox.com/Data/Upload.ashx however for every example I’ve used to try and build this script with it never seems to work.

This is the function in the script I’ve produced in JavaScript that I’m using for a github actions based uploading system

async function uploadAsset() {
	const buffer = fs.readFileSync(`./${process.env.TARGETFILE}`); // This is just the rbxm file

	console.debug('Uploading to Roblox...');
	let response = await axios
		.post(`https://data.roblox.com/Data/Upload.ashx?assetid=${process.env.TARGETASSET}`, buffer, {
			timeout: 60 * 3 * 1000, // 3 mins
			headers: {
				Cookie: `.ROBLOSECURITY=${process.env.ROBLOXCOOKIE}`,
				'User-Agent': 'Roblox/WinInet',
				'Content-Type': 'application/xml',
				Accept: 'application/json',
			},
		})
		.then((d) => d)
		.catch((e) => {
			console.error(e);
			return e;
		});

	if (response.response.status === 403 && response.response.headers['x-csrf-token']) {
		const csrfToken = response.response.headers['x-csrf-token'];
		console.debug('Received CSRF challenge, retrying with token...');

		response = await axios
			.post(`https://data.roblox.com/Data/Upload.ashx?assetid=${process.env.TARGETASSET}`, buffer, {
				timeout: 60 * 3 * 1000, // 3 mins
				headers: {
					'X-CSRF-Token': csrfToken,
					Cookie: `.ROBLOSECURITY=${process.env.ROBLOXCOOKIE}`,
					'User-Agent': 'Roblox/WinInet',
					'Content-Type': 'application/xml',
					Accept: 'application/json',
				},
			})
			.then((d) => d)
			.catch((e) => {
				console.error(e);
				return e;
			});
	}

	if (response.response.status >= 200 && response.response.status < 300) {
		return;
	} else {
		throw new Error(`Unable to upload: ${response.status}`);
	}
}

However, every time it runs when it attempts to upload a new copy of something it seems to always fail. If anyone could help me fix this script to actually work or inform me on how to properly upload to this endpoint, your help would be appreciated!

Thanks in advance Devforum Community!

Edit: Ive tried publishing the model over Rojo but it doesn’t seem to work.

1 Like

I’m not familiar with Roblox’s api, but I have uploaded .rbxms with Noblox.js before, you should check it out if you know JavaScript

1 Like

You might be better off using OpenCloud for this, read Assets API | Documentation - Roblox Creator Hub and grab a token at https://create.roblox.com/dashboard/credentials with the Assets intent.

3 Likes

Are you sure I’ll be able to upload .rbxm files with this? It looks like it only supports models as .fbx files…

I tried your solution, however it seems to always go wrong when I upload with this too, it always returns this when it gets to noblox.setCookie(COOKIE HERE)

Failed to validate cookie: Are you sure the cookie is valid?
Ensure you include the full cookie, including warning text.

The cookie I’m using has come from the .ROBLOSECURITY cookie in my debug menu from firefox.
It also seems to log me out every time I put a new cookie into the env variable I use.

This is how the upload file looks:

import dotenv from 'dotenv';
import fs from 'node:fs';
import nbx from 'noblox.js';

dotenv.config();

const usr = await nbx.setCookie(process.env.ROBLOXCOOKIE);
console.log(`Logged in as ${usr.UserName} [${usr.UserID}]`);

const res = await nbx.uploadModel(
	fs.readFileSync(`./FILE.rbxm`),
	{
		DETAILS ARE IN HERE
	},
	process.env.TARGETASSET
);

console.log(res);

Solved, realised the account I was using was refreshing the cookie.
Disabled it in roblox creator settings and now everything works!
Thanks for the help @yourcomputerhasdied!

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