Unlock seamless workflows and faster delivery with our latest releases- get the details

Issue with loading a document in Sanity Studio after creating it via a POST request.

5 replies
Last updated: May 6, 2020
Hi,I'm working on implementing internationalization via this great package,
sanity-plugin-intl-input .When selecting a language that does not yet exist, it routes to the new document, and a POST request is sent with the new document, and returnDocument=true is set.
The new document is returned in the response, and the document is created. But the Sanity Studio loads the attached image.
Refreshing the studio fetches the document properly.
Any idea what might be wrong, or where to start looking?
May 4, 2020, 1:04 PM
Hi Kenneth, what’s the URL at the moment it shows the error you attached? Does the URL change when you refresh?
The error suggests it cannot get the schema for the type name (
scenario
in this case). But considering it loads successfully on refresh, it seems like this schema type does in fact exist. Could you confirm that
scenario
is a document type, not an object?
May 4, 2020, 5:43 PM
<http://localhost:3333/ss-1116/desk/scenario;04fcb4e9-9453-40b3-a951-e79ff085c644__i18n_fr-FR>
The URL is the same when I refresh the page.

Thats correct,
scenario
is a document type.
To add some more info, I can see that after the POST,a bunch of GET requests with the query
[*[_id in ["drafts.04fcb4e9-9453-40b3-a951-e79ff085c644__i18n_fr-FR","04fcb4e9-9453-40b3-a951-e79ff085c644__i18n_fr-FR"]][0...2]{_id,_rev,_type,_type}][0...1]
is run, with an empty [] as result.
After this, a GET request against
https://{APPID}.<http://api.sanity.io/v1/data/doc/ss-1116/drafts.04fcb4e9-9453-40b3-a951-e79ff085c644__i18n_fr-FR,04fcb4e9-9453-40b3-a951-e79ff085c644__i18n_fr-FR|api.sanity.io/v1/data/doc/ss-1116/drafts.04fcb4e9-9453-40b3-a951-e79ff085c644__i18n_fr-FR,04fcb4e9-9453-40b3-a951-e79ff085c644__i18n_fr-FR>
runs and successfully returns the new document. Type still
scenario
as expected.
May 4, 2020, 6:20 PM
I seem to have found the problem. It was the structure builder that created the problems. After changing it to how the intl-plugin expects the content to be, it seems to work 🙂
May 5, 2020, 12:24 PM
Thanks for digging further into this issue! Glad you figured out what the problem was, because it wasn’t that obvious from the error or the strange behaviour without vs. with refresh. Was the information you needed to resolve this already included in the plugin readme? https://github.com/LiamMartens/sanity-plugin-intl-input (if not, maybe we can ask Liam to add it) 🙂
May 5, 2020, 1:54 PM
Not sure honestly. What I did to solve it was to take the filter used inside the function to get a filtered list, and manually adding it to the documents we are adding translations to.Only thing not working now is the "side-by-side" view, not sure if that's related.
May 6, 2020, 8:16 AM

Sanity– build remarkable experiences at scale

Sanity is a modern 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?