Discussion about adding experimental spaces in Sanity.json and resolving issues with switching between them.

16 replies
Last updated: Nov 5, 2021
HI Team,I just added two sanity spaces adding this "__experimental_spaces”  code into sanity.json
{
 "root": true,
 "api": {
  "projectId": "********",
  "dataset": "production"
 },
 "project": {
  "name": "Sample"
 },
 "__experimental_spaces": [
  {
   "name": "production",
   "title": "Prod",
   "default": true,
   "api": {
    "projectId": "********",
    "dataset": "production"
   }
  },
  {
   "name": "staging",
   "title": "Staging",
   "api": {
    "projectId": "********",
    "dataset": "testsanity"
   }
  }
 ],
 "plugins": [
  "@sanity/base",
  "@sanity/default-layout",

Now I can see a dropdown next to my project name, when I’m switching from ‘prod’ to ‘staging’ from above dropdown, url is got change to
http://localhost:3333/staging/desk/docs but drop down value is still prod and I can see data in my production dataset(because I created my ‘testsanity’ dataset just now, so this should be empty). Any reason to behave like this?
Nov 4, 2021, 5:03 PM
It looks like you have an extra
api
setting above your
experimental_spaces
. Do you still get this behavior if you remove it?
Nov 4, 2021, 11:57 PM
when I execute 'sanity deploy' command after removing extra api section from above sanity.json file following error will returnPS D:\*****-docs-cms> sanity deploy
Error: "D:/****/sanity.json" does not contain a project identifier ("api.projectId"), which is required for the Sanity CLI to communicate with the Sanity API
Nov 5, 2021, 12:08 AM
when I execute 'sanity deploy' command after removing extra api section from above sanity.json file following error will returnPS D:\*****-docs-cms> sanity deploy
Error: "D:/****/sanity.json" does not contain a project identifier ("api.projectId"), which is required for the Sanity CLI to communicate with the Sanity API
Nov 5, 2021, 12:08 AM
can you copy and paste your
sanity,json
here?
Nov 5, 2021, 12:10 AM
{  "root": true,
  "project": {
    "name": "sample"
  },
  "__experimental_spaces": [
    {
     "name": "production",
     "title": "Prod",
     "default": true,
     "api": {
      "projectId": "******",
      "dataset": "production"
     }
    },
    {
     "name": "staging",
     "title": "Staging",
     "api": {
      "projectId": "********",
      "dataset": "testsanity"
     }
    }
   ],
  "plugins": [
    "@sanity/base",
    "@sanity/default-layout",
    "@sanity/default-login",
    "@sanity/desk-tool",
    "@sanity/code-input",
    "markdown",
    "@sanity/color-input"
  ],
  "env": {
    "development": {
      "plugins": [
        "@sanity/vision"
      ]
    }
  },
  "parts": [
    {
      "name": "part:@sanity/base/schema",
      "path": "./schemas/schema"
    }
  ]
}
Nov 5, 2021, 12:11 AM
{  "root": true,
  "project": {
    "name": "sample"
  },
  "__experimental_spaces": [
    {
     "name": "production",
     "title": "Prod",
     "default": true,
     "api": {
      "projectId": "******",
      "dataset": "production"
     }
    },
    {
     "name": "staging",
     "title": "Staging",
     "api": {
      "projectId": "********",
      "dataset": "testsanity"
     }
    }
   ],
  "plugins": [
    "@sanity/base",
    "@sanity/default-layout",
    "@sanity/default-login",
    "@sanity/desk-tool",
    "@sanity/code-input",
    "markdown",
    "@sanity/color-input"
  ],
  "env": {
    "development": {
      "plugins": [
        "@sanity/vision"
      ]
    }
  },
  "parts": [
    {
      "name": "part:@sanity/base/schema",
      "path": "./schemas/schema"
    }
  ]
}
Nov 5, 2021, 12:11 AM
Which version of the Studio are you running?
Nov 5, 2021, 12:13 AM
mmm where can I find it
Nov 5, 2021, 12:14 AM
"dependencies": {    "@sanity/base": "^2.21.0",
    "@sanity/block-content-to-markdown": "^0.0.5",
    "@sanity/code-input": "^2.21.1",
    "@sanity/color-input": "^2.21.2",
    "@sanity/core": "^2.21.0",
    "@sanity/default-layout": "^2.21.0",
    "@sanity/default-login": "^2.21.0",
    "@sanity/desk-tool": "^2.21.0",
    "@sanity/vision": "^2.21.0",
    "get-video-id": "^3.4.1",
    "get-youtube-id": "^1.0.1",
    "prop-types": "^15.7",
    "react": "^17.0",
    "react-dom": "^17.0",
    "sanity-plugin-markdown": "^2.0.2",
    "styled-components": "^5.2.0"
  }
Nov 5, 2021, 12:14 AM
{  "name": "*******",
  "private": true,
  "version": "1.0.0",
  "description": "",
  "main": "package.json",
  "author": "********",
  "license": "UNLICENSED",
  "scripts": {
    "start": "sanity start",
    "build": "sanity build"
  },
  "keywords": [
    "sanity"
  ],
  "dependencies": {
    "@sanity/base": "^2.21.0",
    "@sanity/block-content-to-markdown": "^0.0.5",
    "@sanity/code-input": "^2.21.1",
    "@sanity/color-input": "^2.21.2",
    "@sanity/core": "^2.21.0",
    "@sanity/default-layout": "^2.21.0",
    "@sanity/default-login": "^2.21.0",
    "@sanity/desk-tool": "^2.21.0",
    "@sanity/vision": "^2.21.0",
    "get-video-id": "^3.4.1",
    "get-youtube-id": "^1.0.1",
    "prop-types": "^15.7",
    "react": "^17.0",
    "react-dom": "^17.0",
    "sanity-plugin-markdown": "^2.0.2",
    "styled-components": "^5.2.0"
  }
}
Nov 5, 2021, 12:16 AM
Ok, revert your
sanity.json
back to the original. That wasn't the issue. If you restart your Studio completely do you still get this behavior?
Nov 5, 2021, 12:18 AM
You may also want to run
sanity upgrade
to get on the latest version.
Nov 5, 2021, 12:19 AM
Thank you very much 🙌, it's got resolved once 'sanity upgrade' and next 'npm install' command. 🎉
Nov 5, 2021, 1:06 AM
Thank you very much 🙌, it's got resolved once 'sanity upgrade' and next 'npm install' command. 🎉
Nov 5, 2021, 1:06 AM
Awesome! So glad it's working!
Nov 5, 2021, 1:17 AM
Awesome! So glad it's working!
Nov 5, 2021, 1:17 AM

Sanity– build remarkable experiences at scale

The Sanity Composable Content Cloud is the headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?