REST API document/update returning "406 Not Acceptable"

Do you want to create a native client or integrate with third party applications: webservices are the solution.

Moderators: car031, car031, car031

Locked
viesturs.l
Posts: 6
Joined: Wed Oct 05, 2016 12:15 pm

REST API document/update returning "406 Not Acceptable"

Post by viesturs.l » Thu Oct 13, 2016 1:09 pm

Hi,

I'm using REST API to update file name and tags.
I tested it using this curl request:

Code: Select all

curl -i -u myusername:mypassword -X PUT --header 'Content-Type: application/json' --header 'Accept: text/html' -d '{ "id": 3866653, "fileName": "New Filename" }' 'https://doc.mydmsurl.com/services/rest/document/update'
I get this and there's no reponse:

Code: Select all

HTTP/1.1 406 Not Acceptable
Cache-Control: private
Expires: Thu, 01 Jan 1970 00:00:00 UTC
Date: Thu, 13 Oct 2016 10:51:22 GMT
Content-Length: 0
Server: Undisclosed/8.41
I see this in LOGS

Code: Select all

2016-10-13 11:08:41.223	WARN	org.apache.cxf.jaxrs.utils.JAXRSUtils	No operation matching request path "/services/rest/document/update" is found, Relative Path: /update, HTTP Method: PUT, ContentType: application/json, Accept: text/html,. Please enable FINE/TRACE log level for more details.

2016-10-13 11:08:41.234	WARN	org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper	javax.ws.rs.ClientErrorException: HTTP 406 Not Acceptable at org.apache.cxf.jaxrs.utils.SpecExceptions.toHttpException(SpecExceptions.java:117) at org.apache.cxf.jaxrs.utils.ExceptionUtils.toHttpException(ExceptionUtils.java:162) at org.apache.cxf.jaxrs.utils.JAXRSUtils.findTargetMethod(JAXRSUtils.java:530) at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:177) at ... [message is very long here - can post if needed]
Can anyone help me resolve this? What I need to do, is to be able to update document tags.

*Tried to setup CE 7.5.1 locally, have the same problem.

maansson
Posts: 10
Joined: Wed Sep 28, 2016 12:23 pm

Re: REST API document/update returning "406 Not Acceptable"

Post by maansson » Thu Oct 13, 2016 2:41 pm

Hello, Viesturs.l.

After finding this: http://stackoverflow.com/questions/1425 ... se-in-http
I think your issue could be that you have this: 'Accept: text/html' instead of: 'Accept: application/json'

Maybe?

viesturs.l
Posts: 6
Joined: Wed Oct 05, 2016 12:15 pm

Re: REST API document/update returning "406 Not Acceptable"

Post by viesturs.l » Thu Oct 13, 2016 3:38 pm

Well, when changing Accept types, I'm getting "500 Internal Server Error".
Also, I think there should be 204 response, which returns no content. So I'm not sure what am I supposed to accept here.

Anway, would be nice, if someone from support would give an example, on how to use this properly?

Thanks!

viesturs.l
Posts: 6
Joined: Wed Oct 05, 2016 12:15 pm

Re: REST API document/update returning "406 Not Acceptable"

Post by viesturs.l » Thu Oct 13, 2016 4:40 pm

Looks like I found a solution:

Code: Select all

curl -i -u admin:admin -X PUT -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{"id":3309568,"folderId":3440640,"title":"newTitle","fileName":"newFilename"}' 'http://localhost:8080/services/rest/document/update'
What I don't understand, is WHY I have to add folderId, title and fileName to just change a fileName and why is this not mentioned anywhere?

Anyway, issue is resolved - found this by digging in logs and LogicalDOC source code.

Locked

Who is online

Users browsing this forum: No registered users and 1 guest