FAQ  •  Register  •  Login

Possible issues with PUT in Restlet

<<

mpemberton5

DLNA master

Posts: 120

Joined: Sun Aug 28, 2011 9:01 pm

Location: North Carolina, USA

Post Fri Sep 23, 2011 1:25 pm

Possible issues with PUT in Restlet

I'm having some issues with updating settings via PUT and seems consistent no matter what I do. Everything else works fine.

I've taken a copy of WebUI in PHP and have been patching it to work with 0.6 and I have yet to get it to accept a PUT. I turned on logging and here's what I get:

  Code:
2011-09-23 09:02:59,309 WARN  [RestletApplication] Unable to parse the object with Gson.
com.google.gson.JsonParseException: Expecting object found: "<?xml"
    at com.google.gson.JsonObjectDeserializationVisitor.visitFieldUsingCustomHandler(JsonObjectDeserializationVisitor.java:100)
    at com.google.gson.ReflectingFieldNavigator.visitFieldsReflectively(ReflectingFieldNavigator.java:63)
    at com.google.gson.ObjectNavigator.accept(ObjectNavigator.java:120)
    at com.google.gson.JsonDeserializationContextDefault.fromJsonPrimitive(JsonDeserializationContextDefault.java:85)
    at com.google.gson.JsonDeserializationContextDefault.deserialize(JsonDeserializationContextDefault.java:56)
    at com.google.gson.Gson.fromJson(Gson.java:551)
    at com.google.gson.Gson.fromJson(Gson.java:498)
    at com.google.gson.Gson.fromJson(Gson.java:467)
    at com.google.gson.Gson.fromJson(Gson.java:417)
    at com.google.gson.Gson.fromJson(Gson.java:389)
    at org.restlet.ext.gson.GsonRepresentation.getObject(GsonRepresentation.java:48)
    at org.restlet.ext.gson.GsonConverter.toObject(GsonConverter.java:87)
    at org.restlet.service.ConverterService.toObject(ConverterService.java:158)
    at org.restlet.resource.UniformResource.toObject(UniformResource.java:644)
    at org.restlet.resource.ServerResource.doHandle(ServerResource.java:431)
    at org.restlet.resource.ServerResource.put(ServerResource.java:1170)
    at org.restlet.resource.ServerResource.doHandle(ServerResource.java:521)
    at org.restlet.resource.ServerResource.doNegotiatedHandle(ServerResource.java:587)
    at org.restlet.resource.ServerResource.doConditionalHandle(ServerResource.java:299)
    at org.restlet.resource.ServerResource.handle(ServerResource.java:846)
    at org.restlet.resource.Finder.handle(Finder.java:510)
    at org.restlet.routing.Filter.doHandle(Filter.java:156)
    at org.restlet.routing.Filter.handle(Filter.java:203)
    at org.restlet.routing.Router.doHandle(Router.java:497)
    at org.restlet.routing.Router.handle(Router.java:737)
    at org.restlet.routing.Filter.doHandle(Filter.java:156)
    at org.restlet.routing.Filter.handle(Filter.java:203)
    at org.restlet.routing.Filter.doHandle(Filter.java:156)
    at org.restlet.routing.Filter.handle(Filter.java:203)
    at org.restlet.routing.Filter.doHandle(Filter.java:156)
    at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:151)
    at org.restlet.routing.Filter.handle(Filter.java:203)
    at org.restlet.routing.Filter.doHandle(Filter.java:156)
    at org.restlet.routing.Filter.handle(Filter.java:203)
    at org.restlet.engine.ChainHelper.handle(ChainHelper.java:111)
    at org.restlet.engine.application.ApplicationHelper.handle(ApplicationHelper.java:72)
    at org.restlet.Application.handle(Application.java:388)
    at org.restlet.routing.Filter.doHandle(Filter.java:156)
    at org.restlet.routing.Filter.handle(Filter.java:203)
    at org.restlet.routing.Router.doHandle(Router.java:497)
    at org.restlet.routing.Router.handle(Router.java:737)
    at org.restlet.routing.Filter.doHandle(Filter.java:156)
    at org.restlet.routing.Filter.handle(Filter.java:203)
    at org.restlet.routing.Router.doHandle(Router.java:497)
    at org.restlet.routing.Router.handle(Router.java:737)
    at org.restlet.routing.Filter.doHandle(Filter.java:156)
    at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:151)
    at org.restlet.routing.Filter.handle(Filter.java:203)
    at org.restlet.routing.Filter.doHandle(Filter.java:156)
    at org.restlet.routing.Filter.handle(Filter.java:203)
    at org.restlet.engine.ChainHelper.handle(ChainHelper.java:111)
    at org.restlet.Component.handle(Component.java:388)
    at org.restlet.Server.handle(Server.java:488)
    at org.restlet.engine.http.connector.BaseServerHelper.handle(BaseServerHelper.java:158)
    at org.restlet.engine.http.connector.BaseServerHelper.handleInbound(BaseServerHelper.java:167)
    at org.restlet.engine.http.connector.BaseHelper.handleNextInbound(BaseHelper.java:418)
    at org.restlet.engine.http.connector.Connection.readMessages(Connection.java:695)
    at org.restlet.engine.http.connector.Controller$2.run(Controller.java:95)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:679)
2011-09-23 09:02:59,310 INFO  [LogService] 2011-09-23   09:02:59    127.0.0.1   -   -   23423   PUT /rest/metadata  -   415 554 535 941 http://127.0.0.1:23423  -   -

What this appears to be telling me is that it's trying to parse my XML using GSON (JSON) which is obviously incorrect. So I went back to make sure there wasn't anything different with this submission than with all the other commands sent to the restlet. I couldn't find anything else different. In fact, the metadata section didn't appear to change between 0.5.2 and 0.6, so this should have worked without any code change to the original WebUI in PHP. Based on the REST interface specs, it should default to an XML content type, and all the other REST commands are successful, so I'm at a loss.

If there are other ways that I could test this to make sure I have nothing wrong on my side. Here's what I'm sending:
  Code:
<?xml version="1.0" encoding="UTF-8" ?>
<metadata>
  <audioLocalArtExtractorEnabled>true</audioLocalArtExtractorEnabled>
  <videoLocalArtExtractorEnabled>true</videoLocalArtExtractorEnabled>
  <videoOnlineArtExtractorEnabled>true</videoOnlineArtExtractorEnabled>
  <videoGenerateLocalThumbnailEnabled>true</videoGenerateLocalThumbnailEnabled>
  <metadataLanguage>en</metadataLanguage>
  <retrieveOriginalTitle>false</retrieveOriginalTitle>
  <descriptiveMetadataExtractor>ONLINE_VIDEO_SOURCES</descriptiveMetadataExtractor>
</metadata>

Any help would be appreciated.
Cheers!
Mark
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 16714

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Fri Sep 23, 2011 1:38 pm

Re: Possible issues with PUT in Restlet

I'll have a look at home. In the meantime, can you add the content-type header to see if it helps?
<<

mpemberton5

DLNA master

Posts: 120

Joined: Sun Aug 28, 2011 9:01 pm

Location: North Carolina, USA

Post Fri Sep 23, 2011 1:53 pm

Re: Possible issues with PUT in Restlet

Found it! WebUI in PHP was sending an "Accept: application/xml" in the header which may have been acceptable with 0.5.2 but was making it fail with 0.6. I commended it out and it seems to be working appropriately now. Weird.

Anyway, I was already sending the content-type in the header and as a test I commented it out and it failed. I'll probably be doing additional testing to see if I can confirm this.

I'm hoping to have a fork of WebUI for PHP that works with 0.6 in the next day or so for those eager to convert to 0.6.

Thanks for the quick reply Zip! Again, excellent work my friend.

Mark

Return to Third-party tools integration

Who is online

Users browsing this forum: No registered users and 1 guest

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.