Leaderboard Reset via Cloud Code not Archiving

Hi Folks,

So I have written a Cloud Code script to reset and, optionally, archive leaderboard scores. The scores are reset correctly but fails to archive. Could someone take a look and point out what I'm doing wrong?

const _ = require('lodash-4.17');
const axios = require("axios-0.21");

module.exports = async ({ params, context, logger }) => {
  const { projectId, playerId, environmentId } = context;
  const { groupId, archive } = params;

  const serviceCredentials = 'XXX';
  const resetLeaderboardConfig = {
    headers: {
      Authorization: `Basic ${serviceCredentials}`,
    data: {
      archive: archive

   var apiUrl = `https://services.api.unity.com/leaderboards/v1/projects/${projectId}/environments/${environmentId}/leaderboards/${groupId}_Count/scores`;
    await axios.delete(apiUrl, resetLeaderboardConfig);

  return resetLeaderboardConfig; //just seeing what's in the request


Hi Travis,

Just wanted to start by noting that you may want to delete your service account key and create a new one - we've edited your message to remove the credential but it was temporarily exposed, and so the safest option would be to remove it and generate a new one.

In terms of your question, the archive parameter is a query parameter, not part of the request body! So the correct approach would be to update your URL as such:

var apiUrl = `https://services.api.unity.com/leaderboards/v1/projects/${projectId}/environments/${environmentId}/leaderboards/${groupId}_Count/scores?archive=${archive}`;

I hope this helps!

1 Like

Hi Devin,

Thank you for anonymizing our key. That was a bonehead move. :)

And thank you for your fix as well. I also changed my "data" element to "params", which worked as well.