Jump to content

workflow to update an item


Go to solution Solved by Chiefmas,

Recommended Posts

Chiefmas
Posted

Ok, hopefully this will be my last post and I'll be able to get the last bits from here...

Initially I was trying to submit to the IitemUpdateService using a post to this endpoint(the ID is correct for my test item): /Items/1348003
Using this as the body (double quoting is escaping in code, they are sent in the post as single quotes):

{
    ""TagItems"": [
        {
            ""Name"": ""add1""
        },
        {
            ""Name"": ""add2""
        }
    ]
}

That gives me a 400. I had hoped I could just submit the fields to change to the ItemUpdateService, but I keep getting 400s back, so now I suspect that I actually need to submit the entire BaseItemDto object back? When I check the server logs, the error in the stack trace is:

	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)

So, I'm not sure what I'm doing wrong, otherwise. If I do need the entire BaseItemDto object, is there an easy way to get that back, so I can just edit it and submit it back? The Item service doesn't appear to return a BaseItemDto, rather it seems to return a subset of that. Docs seem to be telling me I should be getting an entire BaseItemDto, but I don't think that's what's happening when I make a call to /Items?ParentID=18060&AnyProviderIdEquals=imdb.tt14961624 I get a single item back, but as I said, it doesn't seem to be a complete BaseItemDto object.

Thanks for all the help, I really appreciate it!

 

  • Solution
Chiefmas
Posted

Ah, ok I found a bug in my code, and I figured out that I am able to add them using the tag service, so I might be set, thanks...

For anyone reading this, I switched to the TagService, i.e. made my endpoint /Items/1348003/Tags/Add and I am able to add tags that way.

Given that I had a bug, I'm going to go back to testing using the ItemUpdateService and see if I can get that working, but I have at least something that works. I'll have to do some more testing to see if the tag service will work better...I need to see what happens when I submit duplicates. I'm kind of hoping that the ItemUpdateService just replaces all the existing tags with what I submit, as that may present some advantages but regardless, I have a way that at least gets the basic thing going.

Thanks!

 

  • Thanks 1
Posted

Thanks for following up.

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