BlairHippo
BlairHippo

Reputation: 9658

Unable to access files from MarkLogic Java API

In the process of showing demoing some new Java code that accesses a local MarkLogic server, I ran into the following error. It pops up any time I try to either load a file, or access its metadata:

Only XML and JSON error messages supported by MarkLogic server.

This is getting triggered in calls to TextDocumentManager.readMetadata() and TextDocumentManager.read(). The code works fine on my machine but NOT on my supervisor's (he's the one seeing the error), which makes me think I tweaked something in the database configuration during development but didn't write it down. Unfortunately, I can't think of what that would be. Does anybody have any suggestions?

Upvotes: 1

Views: 297

Answers (1)

ehennum
ehennum

Reputation: 7335

The message indicates that the server responded with an error without a Content-Type header declaring error content as JSON or XML.

Thus far, we've seen that Java exception only when the server was not initialized as a REST server.

So, please check your connection parameters. If in doubt, use an HTTP client like curl to make the equivalent request of the REST server to verify that the request is accepted.

If the REST server seems to be operational, you can also turn on error logging on the REST server to help debug the Java client.


To answer the followup question (StackOverFlow timed out on the initial answer):

There's a UI for creating a REST server in InfoStudio database configuration.

  • Go to port 8000 at the /appservices/ path.
  • Select the Database from the drop down and click Configure
  • Add a REST API Instance near the bottom of the page

There's also a REST interface for the admin user (not the REST admin user) to create REST instances on port 8002. For information about those services, please see

http://docs.marklogic.com/REST/client/service-management

Upvotes: 2

Related Questions