I ran the script and the only issue I saw is that the error message returned is
statusCode: 400
{"error":"scenes: missing value"}
After I added the scene id, it gave me a job id to poll.
Full script that I ran via node.js
const https = require('node:https');
let accessToken = "XXXXXXXXXX";
function downloadProject() {
const data = JSON.stringify({
project_id: 472797,
name: "Some Project",
scenes: [513888]
});
const options = {
hostname: 'playcanvas.com',
path: '/api/apps/download',
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
}
};
const req = https.request(options, res => {
console.log(`statusCode: ${res.statusCode}`);
let chunks = [];
res.on('data', chunk => {
chunks.push(chunk);
});
res.on('end', () => {
let body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.on('error', error => {
console.error(error);
});
req.write(data);
req.end();
}
downloadProject();
Gave me the response (edited to remove private data):
{"id":1,"scope":{"type":"user","id":1},"created_at":"2023-05-10T14:55:36.567Z","modified_at":"2023-05-10T14:55:36.567Z","status":"running","messages":[],"data":{"owner_id":1,"project_id":472797,"branch_id":"XXXXXXXXX","name":"Some Project","scenes":["513888"],"concatenate":false,"minify":false,"sourcemaps":false,"optimize_scene_format":false,"preload_bundle":false}}