FAQ  •  Register  •  Login

Updating library data using REST API and Cli

<<

smmortazavi

Serviio newbie

Posts: 4

Joined: Mon Feb 20, 2012 9:45 am

Post Sat Mar 31, 2012 5:23 pm

Updating library data using REST API and Cli

Hello,
First of all I should express my gratuitousness towards zip, for this great piece of software. Secondly, I hope I haven't spammed here with a duplicate question but I really could not find a similar question.
I need to update library data using REST API. I used curl :
  Code:
curl -v -H "Content-Type: application/xml"  -X PUT --data @repos http://127.0.0.1:23423/rest/repository

which sends a PUT request with the body data from file named "repos". This is the content of this file:

  Code:
<?xml version="1.0" encoding="UTF-8" ?>
<repository>
  <sharedFolders/>
  <searchHiddenFiles>false</searchHiddenFiles>
  <searchForUpdates>true</searchForUpdates>
  <automaticLibraryUpdate>true</automaticLibraryUpdate>
  <automaticLibraryUpdateInterval>5</automaticLibraryUpdateInterval>
  <onlineRepositories>
    <onlineRepository>
      <id>116</id>
      <repositoryType>FEED</repositoryType>
      <contentUrl>http://gdata.youtube.com/feeds/api/users/lengas32/uploads?v=2&amp;max-result=150</contentUrl>
      <fileType>VIDEO</fileType>
      <repositoryName>Seconds From Disaster</repositoryName>
      <enabled>true</enabled>
    </onlineRepository>
    <onlineRepository>
      <id>117</id>
      <repositoryType>FEED</repositoryType>
      <contentUrl>http://gdata.youtube.com/feeds/api/users/aircrashuploader/uploads?v=2&amp;max-result=150</contentUrl>
      <fileType>VIDEO</fileType>
      <repositoryName>Air-Crash</repositoryName>
      <enabled>true</enabled>
    </onlineRepository>
  </onlineRepositories>
  <maxNumberOfItemsForOnlineFeeds>-1</maxNumberOfItemsForOnlineFeeds>
  <onlineFeedExpiryInterval>2</onlineFeedExpiryInterval>
  <onlineContentPreferredQuality>HIGH</onlineContentPreferredQuality>
</repository>



The problem is that serviio receives this request but does not add the items. I see these lines in the log after the request is sent:
  Code:
2012-03-31 20:14:53,499 DEBUG [OnlineRepositoryDAOImpl] Reading all OnlineRepositories
2012-03-31 20:14:58,258 DEBUG [RepositoryServerResource] Updating repository with values: OnlineRepository [repoType=FEED, fileType=VIDEO, repositoryUrl=http://gdata.youtube.com/feeds/api/users/lengas32/uploads?v=2&max-result=150, repositoryName=Seconds From Disaster, thumbnailUrl=null]
2012-03-31 20:14:58,258 DEBUG [RepositoryServerResource] Updating repository with values: OnlineRepository [repoType=FEED, fileType=VIDEO, repositoryUrl=http://gdata.youtube.com/feeds/api/users/aircrashuploader/uploads?v=2&max-result=150, repositoryName=Air-Crash, thumbnailUrl=null]
2012-03-31 20:14:58,259 DEBUG [OnlineRepositoryDAOImpl] Reading all OnlineRepositories
2012-03-31 20:14:58,261 DEBUG [OnlineRepositoryDAOImpl] Reading an OnlineRepository (id = 116)


but I receive this response from the server :
  Code:
<html>
<head>
   <title>Status page</title>
</head>
<body style="font-family: sans-serif;">
<p style="font-size: 1.2em;font-weight: bold;margin: 1em 0px;">Internal Server Error</p>
<p>The server encountered an unexpected condition which prevented it from fulfilling the request</p>
<p>You can get technical details <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1">here</a>.<br>
Please continue your visit at our <a href="/">home page</a>.
</p>
</body>
</html>


and the library does not get updated. I'm on serviio version 0.6.2 windows.
Any ideas?

Thanks in advance.
<<

jhb50

DLNA master

Posts: 2843

Joined: Thu Jun 30, 2011 9:32 pm

Post Sat Mar 31, 2012 6:09 pm

Re: Updating library data using REST API and Cli

When adding items do not specify an id. Also I believe you must load the whole repository, not just the new items, else the repository will only have the new items and the old ones will be lost.
<<

smmortazavi

Serviio newbie

Posts: 4

Joined: Mon Feb 20, 2012 9:45 am

Post Sat Mar 31, 2012 9:29 pm

Re: Updating library data using REST API and Cli

jhb50 wrote:When adding items do not specify an id. Also I believe you must load the whole repository, not just the new items, else the repository will only have the new items and the old ones will be lost.


Thanks a lot!!!!!
It worked like a charm when I removed IDs. You are right about sending the whole repository, I should send a GET first and add the new items without the IDs.

Return to Serviio Support & Help

Who is online

Users browsing this forum: Google [Bot] and 20 guests

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