diff --git a/public/app/features/dashboard/api/v1.ts b/public/app/features/dashboard/api/v1.ts index f14576d9983..ca8d4cc0c75 100644 --- a/public/app/features/dashboard/api/v1.ts +++ b/public/app/features/dashboard/api/v1.ts @@ -71,18 +71,22 @@ export class K8sDashboardAPI implements DashboardAPI { }; } + // remove resource version because it's not allowed to be set + // and the api server will throw an error + delete obj.metadata.resourceVersion; + // for v1 in g12, we will ignore the schema version validation from all default clients, // as we implement the necessary backend conversions, we will drop this query param if (dashboard.uid) { obj.metadata.name = dashboard.uid; - // remove resource version when updating - delete obj.metadata.resourceVersion; return this.client.update(obj, { fieldValidation: 'Ignore' }).then((v) => this.asSaveDashboardResponseDTO(v)); } obj.metadata.annotations = { ...obj.metadata.annotations, [AnnoKeyGrantPermissions]: 'default', }; + // non-scene dashboard will have obj.metadata.name when trying to save a dashboard copy + delete obj.metadata.name; return this.client.create(obj, { fieldValidation: 'Ignore' }).then((v) => this.asSaveDashboardResponseDTO(v)); }