Sludge Vohaul 22 Posted December 2, 2016 Share Posted December 2, 2016 Hi, I am trying to change a movie's SortName programmatically. This sort of works (it gets changed) but the server replies with a 400 (Bad request) "argument cannot be null. Parameter name : source" Trying the same via the Swagger UI results in the same error. In Swagger UI as well my code I provide the following data: ItemId: a7f784e6e2af890fa954717c2b759743 Body: { "ItemId": "a7f784e6e2af890fa954717c2b759743", "ForcedSortName": "asd" } Is this the way how it should work? What I've found out: Swagger UI says that all (almost all) keys are optional. Except for the "ItemId" in the body (which is not tagged as optional), I suppose the other keys not tagged as optional are also meant to be optional. (I at least cannot think of any reason, why one should always provide for example the "UserItemDataDto.PlayCount" (as it is not tagged as optional)). Anyway, the server logs say that the mentioned error comes from MediaBrowser.Api.ItemUpdateService.UpdateItem() I don't know who exactly is raising the ArgumentNullException, but the UpdateItem() code has IMO issues with the handling of optional values. For example in Swagger UI the key "Tags" is tagged as optional, but the UpdateItem() code looks like this: item.Tags = request.Tags; IMO it should be something like if (string.IsNullOrWhitespace(request.Tags) == false) item.Tags = request.Tags; Currently the existing value gets overwritten with a null (which is then written to the repository via item.UpdateToRepository() in the calling method). To see the impacts copy in Swagger UI the model schema into the body field and post the whole thing (with a valid ItemId of course). The movie's metadata will be gone (i.e. THIS WILL DESTROY YOUR METADATA for the specific movie). Bug? Link to comment Share on other sites More sharing options...
Luke 37112 Posted December 2, 2016 Share Posted December 2, 2016 it doesn't support single field changes in that manner. the endpoint is designed so that you would send back the entire item. In lieu of documentation i would refer to the metadata editor: https://github.com/MediaBrowser/emby-webcomponents/blob/master/metadataeditor/metadataeditor.js and then the apiclient methods that it's ultimately using. Link to comment Share on other sites More sharing options...
Sludge Vohaul 22 Posted December 3, 2016 Author Share Posted December 3, 2016 (edited) Ok, thanks. So in order to change one value (the mentioned sort name for example) one needs to fetch metadata the item already has defined, change the value in question and post the item to the server, basically item = apiClient.GetItem() ChangeSomeValues(item) apiClient.UpdateItem(item) // not implemented in the .Net ApiClient, should do the same as the javascript code) right? Edited December 6, 2016 by Sludge Vohaul Link to comment Share on other sites More sharing options...
Luke 37112 Posted December 3, 2016 Share Posted December 3, 2016 Correct yes. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now