Amything 4 Posted February 16 Share Posted February 16 I'm trying to update properties for an item. I'm probably doing something really basic wrong. My stripped down Python code is: url = "https://localhost:443" api_key = "xxx" user_id = "xxx" item_id = "123" header = {"X-MediaBrowser-Token": api_key} get_item_url = f"{url}/emby/users/{user_id}/items/{item_id}" response = requests.get(get_item_url, headers=header) item = response.json() # Item gotten successfully item["Name"] = "Test name" update_item_url = f"{url}/emby/Items/{item_id}?api_key={api_key}" response = requests.post(update_item_url, data=json.dumps(item), headers=header) print(response.status_code, response.text) Result is: 500 The method or operation is not implemented. Link to comment Share on other sites More sharing options...
Luke 37066 Posted February 16 Share Posted February 16 HI, what does the server log say? Link to comment Share on other sites More sharing options...
Amything 4 Posted February 16 Author Share Posted February 16 Hi Luke, here is the log: Quote 2024-02-16 12:19:16.373 Info Server: http/1.1 POST http://emby_remote_ip/emby/Items/5967285?api_key=x_secret6_x. UserAgent: python-requests/2.31.0 2024-02-16 12:19:16.374 Error Server: Error processing request *** Error Report *** Version: 4.8.0.80 Command line: /app/emby/system/EmbyServer.dll -programdata /config -ffdetect /app/emby/bin/ffdetect -ffmpeg /app/emby/bin/ffmpeg -ffprobe /app/emby/bin/ffprobe -restartexitcode 3 Operating system: Linux version 5.4.0-163-generic (buildd@lcy02-amd64-067) (gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.2)) #180-Ubuntu SMP Tue Sep 5 13:21:23 UTC 20 Framework: .NET 6.0.25 OS/Process: x64/x64 Runtime: app/emby/system/System.Private.CoreLib.dll Processor count: 16 Data path: /config Application path: /app/emby/system System.ArgumentNullException: System.ArgumentNullException: Value cannot be null. (Parameter 'source') at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at Emby.Api.ItemUpdateService.UpdateItem(BaseItemDto request, BaseItem item) at Emby.Api.ItemUpdateService.Post(UpdateItem request) at Emby.Server.Implementations.Services.ServiceController.<>c__DisplayClass8_0.<VoidActionDelegate>b__0(Object service, Object request) at Emby.Server.Implementations.Services.ServiceController.Execute(HttpListenerHost appHost, Object requestDto, IRequest req, Type serviceType) at Emby.Server.Implementations.Services.ServiceHandler.ProcessRequestAsync(HttpListenerHost httpHost, IServerApplicationHost appHost, IRequest httpReq, IResponse httpRes, IStreamHelper streamHelper, RestPath restPath, String responseContentType, CancellationToken cancellationToken) at Emby.Server.Implementations.HttpServer.HttpListenerHost.RequestHandler(IRequest httpReq, ReadOnlyMemory`1 urlString, ReadOnlyMemory`1 localPath, CancellationToken cancellationToken) Source: System.Linq TargetSite: Void ThrowArgumentNullException(System.Linq.ExceptionArgument) 2024-02-16 12:19:16.374 Info Server: http/1.1 Response 400 to host11. Time: 1ms. POST http://emby_remote_ip/emby/Items/5967285?api_key=x_secret6_x 2024-02-16 12:19:20.704 Info SessionManager: Reissuing access token: 607d2f0d492b45d89e06529ebdff6854 2024-02-16 12:19:20.840 Info Server: http/1.1 POST http://emby_remote_ip/emby/Sessions/Capabilities/Full?X-Emby-Client=Emby Web&X-Emby-Device-Name=Google Chrome Windows&X-Emby-Device-Id=3e9ed5f4-a0e6-42d6-b0fe-1db551d02988&X-Emby-Client-Version=4.8.1.3&X-Emby-Token=x_secret7_x&X-Emby-Language=en-gb&reqformat=json. UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 2024-02-16 12:19:20.844 Info Server: http/1.1 Response 204 to host11. Time: 4ms. POST http://emby_remote_ip/emby/Sessions/Capabilities/Full?X-Emby-Client=Emby Web&X-Emby-Device-Name=Google Chrome Windows&X-Emby-Device-Id=3e9ed5f4-a0e6-42d6-b0fe-1db551d02988&X-Emby-Client-Version=4.8.1.3&X-Emby-Token=x_secret7_x&X-Emby-Language=en-gb&reqformat=json Link to comment Share on other sites More sharing options...
Luke 37066 Posted February 16 Share Posted February 16 OK if you use the web browser debugger to monitor what the web app sends, how does that compare to your request? Link to comment Share on other sites More sharing options...
TeamB 2352 Posted February 16 Share Posted February 16 I had problems using this as well. It is hard to get ALL the data you need to do the update, a standard cal to get item info does not appear to get all the item data you need to make the update call. Even if I added all the fields used in the Web Client I still had the same error Value cannot be null. (Parameter 'source') So I gave up and wrote my own plugin that accepts just the details I want to update, not a good options but worked in my situation. I think we need two things, the first one is the best option I feel. - API endpoint that can just update a single or multiple details of an item, just fill in the Item details you want updated and call update - Way of getting an Item that has all the fields needed to do the update. 1 Link to comment Share on other sites More sharing options...
Amything 4 Posted February 17 Author Share Posted February 17 @LukeThank you for that tip, using the web client to see exactly what is happening helped get me on the right track. @TeamBYeah would be nice to just be able to modify a specific property. However I did manage to get it to work with simply posting the same item after getting it previously. My problem was doing: data=item instead of json=item in the request. Full working sample: url = self.server_url api_key = self.api_key user_id = self.user_id header = {"X-MediaBrowser-Token": api_key} item_id = "1389020" get_item_url = f"{url}/emby/users/{user_id}/items/{item_id}" response = requests.get(get_item_url, headers=header) item = response.json() item["Name"] = "Test name" update_item_url = f"{url}/emby/Items/{item_id}?api_key={api_key}" response = requests.post(update_item_url, json=item, headers=header) print(response.status_code, response.text) 1 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