Beeminder Forum

404 error trying to modify goals via the API

I’m trying to use the following TypeScript code to update Beeminder goals. However, I keep getting 404 errors even though I’ve done logging and I’m certain the goals exist. Any advice on how to solve this issue? I thought it might be an issue with how I’m using OAuth tokens for auth, but I’m not having issues with getting goals using the oath tokens, and I’m not getting auth errors–I’m getting 404s.


  "errorType": "Error",
  "errorMessage": "Fetch error: 404 - Not Found -",
  "trace": [
    "Error: Fetch error: 404 - Not Found -",
    "    at updateGoal (/var/task/functions/cron/index.js:153054:11)",
    "    at processTicksAndRejections (internal/process/task_queues.js:97:5)",
    "    at async /var/task/functions/cron/index.js:153254:7",
    "    at async Promise.all (index 1)",
    "    at async /var/task/functions/cron/index.js:153244:5",
    "    at async Promise.all (index 0)",
    "    at async doCron (/var/task/functions/cron/index.js:153238:3)",
    "    at async Runtime.handler (/var/task/functions/cron/index.js:153261:3)"


export async function updateGoal(
    user: string,
    token: string,
    slug: string,
    fields: {roadall: Roadall}
): Promise<Omit<Goal, "datapoints">> {
  const url = `${user}/goals/${slug}.json`;
  const options = {
    method: "post",
    body: JSON.stringify(fields),
  const response = await fetch(`${url}?access_token=${token}`, options);

  console.log({user, token, slug, url, options, fields});

  if (!response.ok) {
    throw new Error(`Fetch error: ${response.status} - ${response.statusText} - ${url}`);

  const data = await response.json();

  if (data?.errors) {
    throw new Error(data.errors.message);

  return data;
1 Like