Hitting 400 when trying to update machine via API

Hi, I’m hitting 400 errors when trying to update a machine via the Machines API. I’m getting 400 status response when calling POST v1/apps/{appId}/machines/{machineId}.

I’m calling with body of whole config, and I’ve tried with both the machine leased and unleased. Any idea what I might be doing wrong? This is the same config that I use when creating a machine via API, which works fine.

async updateMachine(
    appId: string,
    machineId: string,
  ) {

    const response = await fetch(
      `${FLY_MACHINES_API_URL}/apps/${appId}/machines/${machineId}`,
      {
        method: 'POST',
        headers: {
          Authorization: `Bearer ${process.env.FLY_API_KEY}`,
          'Content-Type': 'application/json',
        },
        body: JSON.stringify({
          config: this.createMachineConfig(),
        }),
      }
    )

    return await response.json()
  }
1 Like

Actually sorry, I was feeding in the config wrong unfortunately.

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