REST API fetch a field

I am trying to fetch just one field (API ID: uid) of document type (blog_post), but I don't get the desired response. (My Response is the same one, as without the parameter fetch)

My URL is as follows: https://my-blog.prismic.io/api/v2/documents/search?ref=XXX&fetch=blog_post.uid

What could be wrong?

Hello Tobias,

Welcome to the Prismic Forum and thanks for reaching out to us.

I tried to fetch only UID field of page document with my repository and got the expected result. Please find attached screenshot:

Are you getting the same output? If not you can send me screenshot as well.

And could you please share the username of your repository so It would be easy to find in our system?

Thanks,
Priyanka

Hello,

Thanks for sharing more details. I've checked the API response with this URL:
https://anybill-blog.prismic.io/api/v2/documents/search?ref=X7wXgBEAACYAh_n-&fetch=blog_post.uid#format=json

There is no way to exclude the metadata (uid, tags, type, etc) in the response. It's only the content fields in data that you can control by search parameters.

And getting the expected result as above. Please find the screenshot:

So you need to pass search parameter reference in the anybill-blog repository.

Let me know if you have any other doubt.

Thanks,
Priyanka

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.