Getting 422 (Unprocessable Entity) when attempting to create a machine with the REST API

Hello team,

I’m getting the error 422 (Unprocessable Entity) when I try to create a machine using the http://_api.internal:4280/v1/apps/<appId>/machines endpoint.

I’ve been using this API for several months now without issues and I didn’t change any of my code.

Did anything change on your end?

Here is the payload I’m sending:

const machine = (await this.restClient
      .post(`apps/${props.appId}/machines`, {
        json: {
          name: 'postgres',
          region: this.region,
          config: {
            image: `ghcr.io/snaplet/postgres:${postgresVersion}-alpine.v1.0.0`,
            guest,
            env: {
              PGDATA: '/var/lib/postgresql/data/pgdata',
              POSTGRES_PASSWORD: props.postgresPassword,
            },
            mounts: [
              {
                volume: props.volumeId,
                path: '/var/lib/postgresql/data',
              },
            ],
            services: [
              {
                ports: [
                  {
                    port: 5432,
                  },
                ],
                protocol: 'tcp',
                internal_port: 5432,
              },
            ],
          },
        },
      })
      .json()) as Machine

Thanks for your help. :pray:

It’s solved, we hit a soft limit. :smile:

For others reaching this thread: the body of the error response should contain details about the error.

1 Like