Jump to content

Recommended Posts

NoEmbyNoFun
Posted

Hello all

I'd like to update an item (a movie) using the code pattern from PenkethBoy ( Setting Folder Sort Sequence via API - Developer API - Emby Community )

The information is fetched using GET /emby/{UserId}/items/{ItemId}.
Then exactly two pieces of information are changed: UserData.PlayCount and UserData.Played.
Then the information should be updated using POST /emby/items/{ItemId}.

# edit item
$item.UserData.Played    = $true
$item.UserData.PlayCount = 1

# update item
$url    = $es + "/Items/73667?api_key=" + $ac
$result = Invoke-Webrequest -uri $url -Method POST -Body ( $item | ConvertTo-Json ) -ContentType "application/json; charset=utf-8"

# returns
StatusCode        : 204
StatusDescription : No Content
Content           : {}
...

Unfortunately this POST does not work as hoped. It returns 204 with no content and the item is not updated.

In the Swagger UI the code 204 is not explained. In this forum I didn't find anything about it. Also in the wiki I found no hints regarding updating of items.

What am I missing? (The user has the right to manage the emby server). Is there any further documentation?

Many thanks in advance for any hint.

Dani

(Environment: Emby 4.5.4.0, Powershell-Script on Windows 10)

Posted (edited)

204 is a status that means everything went fine.

The difference between it and 200 is that there will be no content in the response.

Are you sure the item isn't updated?

Edited by roaku
NoEmbyNoFun
Posted

Unfortunately yes, re-query of the item still shows it as not watched.

Also using the website shows the movie as not seen.

PenkethBoy
Posted (edited)

did you pull down the FULL item record first and update that - as it wont work if you dont

also not sure updating user data via an item will work that way - might but not tried it

Edited by PenkethBoy
NoEmbyNoFun
Posted

Yes, I pulled down the full item record with 

$url = $es + "/Users/" + $uid + "/Items/73667" + "?api_key=" + $ac
$result = Invoke-WebRequest -Uri $url -Method GET -ContentType "application/json"
$item = $result.Content | ConvertFrom-Json

Is there another way than "POST /item/{ItemId}" to update an item?

Posted

Have you tried comparing your http request to what the web app sends when using the metadata editor? You can do this by following the network requests in the browser debugger.

NoEmbyNoFun
Posted
17 hours ago, Luke said:

Have you tried comparing your http request to what the web app sends when using the metadata editor? You can do this by following the network requests in the browser debugger.

Thanks for the hint, the metadata editor doesn't show the fields concering the play state. 

Thanks to your hint I saw that the endpoint "/Users/{UserId}/PlayedItems/{Id}" is used for the user play state. I'll try it with that one. 

To be continued.

NoEmbyNoFun
Posted

Finally, it worked with the endpoint "POST /Users/{UserId}/Items/{ItemId}/UserData". 😃

Thanks a lot for all hints. 👍

(Topic can be closed.)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...