API-migration

Hello,
I'm trying to migrate content from the prod repository to my lab repository via API migration. It's complaining about the JSON format when I try to migrate...

What's the purpose of the migration API if I have to manually fix the format for all my documents?

There must be a smoother way?

Export job:

My import job:

Hi @chawder.ahrtyn. You shouldn't need to fix the format, you should be able to use the queried JSON directly. What is it complaining about?

Hello,
I can only see that I'm getting a bad request (400) without any details. I have cleared the lab repository of all data/custom post-types so that it doesn't cause any conflicts, but I'm still getting a bad request.

@Levi
My lab repository is now completely empty, no documents and no post types. I'm trying to migrate data from another repository and I get status 400 with the status text "Bad Request".

Does the repository that you're migrating to have your exact content models from the original?

Yes, it does. Let me give you some background to make things clearer.

Our website is built with Gatsby and the old Prismic. We're currently rebuilding it with Next 14. That's when we got in touch with Slice Machine and the new page builder. When I started experimenting with our lab repository, I noticed that we began losing data during the migration. We then decided not to touch our production repo until we're completely comfortable with Slice Machine and the page builder.

We rebuilt the entire project in a couple of days, but migrating data has taken a few weeks now. I've worked with other CMS before, but it's never been this complicated and unclear, unfortunately.

We urgently need help with this. Our website is visited by many daily, and we absolutely cannot afford to lose production data. We hope to get assistance or a guide soon on how we can migrate data smoothly.

Hi @chawder.ahrtyn

I'm Alaina, the Product Manager responsible for the Migration API.

Can you (via private message) please provide us with an example of your entire json request to the Migration API so our team can take a deeper look at why you are receiving this error?

Also, if you're willing to provide specific feedback around the particular points that have made this difficult for you or prompted you to look for support and guidance, it would help us to make the migration experience more smooth in the future.

Thanks

Hi there,

It looks like I'm also getting a strange error regarding valid JSON when trying to use the Migration API.

The status code appears to be 404 even though the document ID is correct and I appear to be able to authenticate successfully. However, this is the response body that I'm given back.

SyntaxError: Unexpected token 'A', "Assets wit"... is not valid JSON
    at JSON.parse (<anonymous>)
    at parseJSONFromBytes (node:internal/deps/undici/undici:4292:19)
    at successSteps (node:internal/deps/undici/undici:4274:27)
    at fullyReadBody (node:internal/deps/undici/undici:2695:9)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async consumeBody (node:internal/deps/undici/undici:4283:7)

Here is the response text value as well:

Assets with following ids not found: Y8w0MRAAAG3TZ0yu

Further inspection shows me that the ID that is being returned from my Prismic client query is the correct ID according to the URL in the Prismic editor. However, the above error message is reporting a completely different ID.

The endpoint that I'm POST-ing to has the correct ID: https://migration.prismic.io/documents/Y8t0pxAAAG3TZAKm/.

Hi @crcollver

Thanks for your feedback.

The error message you received is referring to an asset (e.g. an image or some other media file) with id: Y8w0MRAAAG3TZ0yu that could not be found in the media library of your repository.

In order to resolve this issue, make sure the media file you are trying to add to your documents exists in your media library. You can utilize the Asset API to GET all your repository's assets and check that asset's id or to upload a new asset.

You can then insert the new asset id in your document json and try your POST request to the Migration API again.

Please let us know how the error message you received could be made more clear, so we can improve this point in the future.

1 Like

Hi @alaina.koerber,

Whoops, that's my bad for not correlating the two APIs. The error message is clear.

I did some digging, and the Asset ID that it is complaining about is not being returned by the Asset API endpoint. However, for some reason the document still shows this image correctly and the URL is still available. Does this happen when content editors add an image to a document, but then accidentally delete that image from the media library?

After I corrected the offending image, I was able to successfully push to the Migration API. Thank you!