Hi Sam,
We are trying to take the backup of all the documents and custom type to our AWS bucket using Ruby on Rails application. Our plan is to use those backup files via Prismic import/export (Import/Export - Documentation - Prismic) when needed.
Issue:
The json format of documents fetch via API is different from the format exported via prismic import/export option.
Questions:
- Is there any better alternative way to use prismic (import/export)feature via API.
- If no, then how can I fetch the Prismic document in same format as documents exported via (import/export) option.
Code snippet we are using
api = Prismic.api(
"https://test.prismic.io/api/v1",
access_token: '',
api_cache: CACHE,
cache: CACHE
)
docs = api.query(Prismic::Predicates.at("document.type", 'doc_type'),
{ "pageSize" => PAGE_SIZE, "page" => page_number })
docs.results.map { |doc| upload_to_aws_bucket(doc.to_json, "#{custom_type}/#{doc.id}.json") }
Format of document fetched via api mentioned above
[
["key", { "value": "value" }],
[
"body",
{
"slices": [
{
"slice_type": "slice #1",
"slice_label": null,
"non_repeat": {
"title": {
"blocks": [
{
"text": "text",
"spans": [],
"label": null
}
]
},
"description": {
"blocks": [
{
"text": " description",
"spans": [],
"label": null
}
]
}
},
"repeat": []
},
{
"slice_type": "slice #2",
"slice_label": null,
"non_repeat": {
"heading": { "value": "" },
"description": {
"value": ""
},
"cta_text": { "value": "" }
},
"repeat": []
}
]
}
]
]
]
Regards
Vishal Verma