Cannot locate a ref to query a draft release

I need to retrieve some uid field data for documents from a draft content release, my "test" release. I can see the test release exists in the API Explorer for my repo, and that it includes one of the unpublished documents that I wish to retrieve the data from.

When I call client.getRefs(); in the repo only one ref is returned, the master ref, rather than additionally returning a ref that points to the content from the "test" release. How do I obtain a ref that will enable me to query data from the full set of content of the test release?


prismic-refs-console-logged

Hello @katie1,

Welcome to Prismic community, and thanks for reaching out to us.

If you want access to the other refs when you call client.getRefs(). In that case, You should go to API access under setting > API & security > Repository security > API access and switch to Private API, generate an access token for master+release, and input the access token where you created Prismic client.

Let me know if this works for you.

Thanks,
Racheal.

@racheal.orukele Thank you, generating the right token (for master+refs) had been the issue.

For anyone else interested, once the correct ref was being included in the repo's access token, I was able to get the 'preview token' straight off the preview's req object and pass it down to all of the data fetching functions in the repo to preview the correct set of data.

In each data fetching function I used client.queryContentFromRef(ref);, ref being the preview token in its entirety. However, this function also worked when the ref was formatted as standalone, the string of letters/numbers as seen in the API browser screenshot.

1 Like

@katie1 I'm glad to hear that. Let us know if you have any other questions.