MarkLogic 8 - Rest Endpoint Returning XML even though we specify JSON

97 views Asked by At

http://localhost/v1/documents?format=json&uri=%2Fdocs%2F1234.json

It looks like this URL is giving us XML instead of JSON which is causing some issues.

I believe this started happening once we upgraded to Marklogic 8.

You can see we are specifying json which seems right based on this: https://docs.marklogic.com/REST/GET/v1/documents

How do I get this to return JSON?

2

There are 2 answers

0
Dave Cassel On BEST ANSWER

In MarkLogic 6 and 7, JSON documents were represented internally as XML, that being the standard hierarchical document format supported in those versions. Access through the REST API was transparently JSON for read & write, it was just different under the hood. In MarkLogic 8, JSON is a native format, so the transformations went away. MarkLogic's Support team has an article about how JSON is handled in versions 6, 7, and 8 -- that should help you.

0
grtjn On

You can do effectively the same using MLCP as well, with the additional benefit that you can repeat the migration easier, optionally against a different target environment or database, and/or add extra tweaks if you like. Export your database files with archive mode, and reimport with this transform:

https://github.com/marklogic/demo-cat/blob/develop/src/transform/to-json.xqy

We did this for an internal migration of demo-cat from MarkLogic 7 to 8. The steps we took are documented here:

https://github.com/marklogic/demo-cat/blob/develop/migration.md

HTH!