Search code examples
firebasegoogle-api-js-client

How do I call gapi.client.firebase.projects.iosApp.create with the correct arguments?


I've authenticated and gotten as far as programmatically setting up a GCP project, followed by adding Firebase management and adding a Firebase project.

Finally, I want to be able to call: https://firebase.googleapis.com/v1beta1/myProject/iosApps but I get a 400 invalid arguments error.

It doesn't say which argument, so I've been trying with the API explorer to try each one, but with no luck

export async function addAppDetails(project) {
  // eslint-disable-next-line no-undef
  await gapi.client.firebase.projects.iosApps
    .create({
      parent: `projects/${project.id}`,
      resource: {
        name: **something here?**,
        appId: **something here?**,
        displayName: project.appName,
        projectId: project.id,
        appStoreId: "",
        bundleId: `com.company.${project.appName.replace(/\s+/, '').toLowerCase()}`,
      },
    })
    .then(operation => operation.result);
}

The API says I should pass a valid IosApp object: https://firebase.google.com/docs/projects/api/reference/rest/v1beta1/projects.iosApps#IosApp

{
  "name": string,
  "appId": string,
  "displayName": string,
  "projectId": string,
  "bundleId": string,
  "appStoreId": string
}

But it also says appId is generated by Firebase and name contains appId. This seems like a circular dependency? How do I get an appId without creating an app, that needs an appId?


Solution

  • It turns out that the documentation is wrong.

    You should only send displayName and bundleId, not a full IosApp object, otherwise you will get a 400 error.