Jump to content

ItemUpdateService : POST ​/Items​/{ItemId} failes with 204


NoEmbyNoFun

Recommended Posts

NoEmbyNoFun

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)

Link to comment
Share on other sites

roaku

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
Link to comment
Share on other sites

NoEmbyNoFun

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

Also using the website shows the movie as not seen.

Link to comment
Share on other sites

PenkethBoy

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
Link to comment
Share on other sites

NoEmbyNoFun

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

NoEmbyNoFun
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.

Link to comment
Share on other sites

NoEmbyNoFun

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

Thanks a lot for all hints. 👍

(Topic can be closed.)

Link to comment
Share on other sites

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...