Use API to export and import to another Org

Hi,

I used the Content API to retrieve a Page a built.
I wanted to use the data retrieve to create the same page on another Organisation with the Write API but it didn’t worked :
-First I stored the “data” content in an environment variable

CONTENT=$(curl -X GET "https://cdn.builder.io/api/v2/content/page?apiKey={myApiKey}&query.id={myPageID}&limit=1" -H "accept: */*" | jq '.results[].data')

-Then I wanted to use the result and create a page:

curl https://builder.io/api/v1/write/page -X POST -d '{ "name": "Test API", "data": '"$CONTENT"' }' -H 'Authorization: Bearer bpk-{privateKey}'

Output:

{"id":"06b0e76be84f4cd2a6b167b8ca6812d2","priority":-12,"name":"","published":"draft","createdDate":1588267616133,"modelId":"3edb0f89273849fdb07301511449334e","ownerId":"7f6932b3bcf34cc1aa9d69b9612f19db","data":{},"{ ***here was my json*** }" }

But in the interface it’s totally empty:


Am I doing something wrong ?
Is there a better way to export/import pages ?

Thanks!

In the code above $CONTENT is a string and need to be parsed to JSON before sending it to the write API, try removing the surrounding “”
-d '{ "name": "Test API", "data": $CONTENT }'

If this is a one-off usage you can always just right click on any page and download builder.json then upload it on any other builder content pages.