Page 1 of 2

REST -> application/json -> No message body writer has been found for response class FolderList.

PostPosted:Wed Oct 21, 2015 9:32 am
by flip
Whenever I try to make a REST request without a specified "accept" header, I get XML as result.
However, when I set the "accept" header to "application/json" I get 500 Server Error and "No message body writer has been found for response class FolderList."

Steps to reproduce:
-> download newest OpenKM Community Version (6.3.1)
-> start, add few documents and folders
-> http://localhost:8080/OpenKM/services/r ... xxxxxxxxxx
-> add header "accept: application/json"

Is there any workaround or am I doing something wrong?

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

PostPosted:Wed Oct 21, 2015 7:27 pm
by sochoa
I advise you to use the SDK became increasingly SDK method is exemplified

NEW SDK VERSIONS FOR JAVA, PHP AND .NET RELEASED

More information about SDK for Java.
http://docs.openkm.com/kcenter/view/sdk4j/

More information about SDK for PHP.
http://docs.openkm.com/kcenter/view/sdk4php/

More information about SDK for .NET.
http://docs.openkm.com/kcenter/view/sdk4net/

but will review the issue because no returns JSON

Greetings

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

PostPosted:Thu Oct 22, 2015 5:47 pm
by jllort
As sochoa suggested to you we encourage using one of the SDK.

However you can check with curl command line
Code: Select all
$ curl -u okmAdmin:admin -H "Accept: application/json" \
   http://localhost:8080/OpenKM/services/rest/folder/getChildren?fldId=3492d662-b58e-417c-85b6-930ad0c6c3cf

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

PostPosted:Wed Nov 11, 2015 7:58 am
by Catscratch
Edit: I solved the problem. Indeed it was a CXF dependency problem. I documented the solution in JIRA:
http://jira.openkm.com/browse/OCM-6
Would be nice if you can modify community sources as described.

- old post -
Hi,

using SDK is not a solution. Because SDK is only available for Java and PHP. I got the same problem when trying to communicate via Javascript. Seems you forgot some annotations in the code or an own object wrapper for JSON. Thats a common issue when you try to return a whole own object (like FolderList) instead of some primitive objects like Map or List.

Here is the backend log:
Code: Select all
2015-11-10 16:59:02,350 [http-bio-0.0.0.0-18080-exec-175] WARN  org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor- No message body writer has been found for response class FolderList.
Besides, it's the same for every own object you return. Like (folder, document, ...):
Code: Select all
2015-11-10 16:55:04,825 [http-bio-0.0.0.0-18080-exec-131] WARN  org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor- No message body writer has been found for response class Folder.

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

PostPosted:Fri Nov 13, 2015 7:21 am
by jllort
Thanks, usually us we're using XML an we had not detected it. As soon as possible we will solve it on source code.

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

PostPosted:Tue Dec 29, 2015 10:19 am
by pavila
Does this command line work without the modification?
Code: Select all
curl -u okmAdmin:admin -H "Accept: application/json" http://localhost:8080/OpenKM/services/rest/test/getComplex

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

PostPosted:Mon Jan 18, 2016 11:04 am
by Catscratch
This is working.

Answer:
{
"author": "Kiko",
"date": "2016-01-18T12:04:16.072+01:00",
"path": "/one/path",
"text": "Test content message"
}

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

PostPosted:Wed Jan 27, 2016 6:35 pm
by pavila
Wonderful :)

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

PostPosted:Mon Mar 06, 2017 9:22 am
by Petr_Valenta
Hello

I have downloaded a Development environment Openkm-6.3-community-portable-dev-1.0 (Windows) on 1.3.2017.

I face the same problem with OpenKM/services/rest/document/createSimple. When I create a document, I receive a message mentioned here.

But I have the same problem with OpenKM/services/rest/test/getComplex. It ends up with the same message.

If I use XML, it seems ok. But I need a json.

Could you hlep me please?

Thanks a lot in advance

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

PostPosted:Wed Mar 08, 2017 7:38 pm
by jllort
Take a look here:
https://docs.openkm.com/kcenter/view/sd ... #Jarsample

If when you execute from eclipse will going right, but when you exeucte a jar fails, then probably you have a wrong pom.xml ( it's a problem while creating jar file, exists two dependences with same file name, and the files by default are not merging, are overwritten, the sample pom.xml in the documentation solves it ).

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

PostPosted:Thu Mar 09, 2017 3:56 am
by Petr_Valenta
Hello

Thank you very much for your answer.

But there is no construction in the pom.xml distributed within "Openkm-6.3-community-portable-dev-1.0 (Windows)" using "maven-assembly-plugin" or "maven-shade-plugin" (as mentioned in the link above). Should I add it into pom.xml? If yes - where?

As for pom.xml - it is unchanged version, I'm using your pom.xml. And it does not look like having any problem. The result seems functional except for the problem described here.

Any suggestion what to to do next?

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

PostPosted:Thu Mar 09, 2017 9:46 pm
by jllort
You are using REST outside OpenKM has not sense using REST webservices from OpenKM.war file, from OpenKM.war you must use the API ( https://docs.openkm.com/kcenter/view/ok ... ption.html ). Portable edition comes with several project, one is the build of OpenKM source code where has not sense using from there the webservices.

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

PostPosted:Fri Mar 10, 2017 3:28 am
by Petr_Valenta
Hello

I'm afraid we don't understand each other.

I have 3rd party application on the customer's site and I need to communicate from it with OpenKM by REST. And I need to extend services by my own.

I have built OpenKM by means of Openkm-6.3-community-portable-dev-1.0 (Windows). When I test both original and custom services with application/xml, they work with no problem. But when I use application/json (which is the required way), both sets of services fail.

What do I need to change in your sources to be able to communicate by application/json?

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

PostPosted:Fri Mar 10, 2017 7:41 am
by jllort
It fails only in creation document or in any method ?
About the remote application, how are you creating the client ( it's a war application and you are creating from there, or you are creating a third-party-application -> man-in-the-middle -> what does it ? )

Re: REST -> application/json -> No message body writer has been found for response class FolderList.

PostPosted:Fri Mar 10, 2017 8:10 am
by Petr_Valenta
There is failing the return of creating a document - from both the original service and from my custom service. The document itself is created in both cases, but the final status of the call is an error.

The third party application is assembling a JSON request "manually" and sends it through a middleware network layer to OpenKM.

As for other commands

curl -u okmAdmin:admin -H "Accept: application/json" -X POST -H "Content-Type: application/json" -d '/okm:root/newfolder' http://localhost:8080/OpenKM/services/r ... eateSimple --> RepositoryException: Invalid path: '/okm:root/newfolder'
This is not working for any tested path.

curl -u okmAdmin:admin -H "Accept: application/json" -X GET http://localhost:8080/OpenKM/services/r ... word=santo
No message body writer has been found for response class QueryResultList.

curl -u okmAdmin:admin -H "Accept: application/json" http://localhost:8080/OpenKM/services/r ... 85fdf6330a
No message body writer has been found for response class FolderList.

I did not test every service but it looks like a problem across all of them.