Fail to create an App in Google App Engine using the Web API. Error: 409 - This application already exists and cannot be re-created

Viewed 2057

I'm trying to use the Google Cloud web API to create an App in App Engine as described in the official documentation (https://cloud.google.com/appengine/docs/admin-api/creating-an-application). I use:

When I do an HTTP POST using node-fetch as follow:

fetch('https://appengine.googleapis.com/v1/apps', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        Authorization: `Bearer ${token}`
    },
    body: JSON.stringify({ 
        id: projectId,
        locationId:'australia-southeast1'
    })
})

Then I receive this error message:

{
 "code": 409,
 "message": "This application already exists and cannot be re-created.",
 "status": "ALREADY_EXISTS"
}

It's really weird as my project id as no App Engine defined yet.

Does anyone know what's happening here?

1 Answers

At least a while ago creating a project (manually) automatically created the GAE app resource associated with it. From the doc you referenced:

If you choose to use an existing GCP project, you must ensure that the project does not already contain the Application resource because projects support only a single App Engine application. To check if your GCP project already contains the Application resource, you can use either the apps.get method or run the gcloud app describe command.

Related