Jump to content

Creating Collections via API in Emby 4.9.0.46


Recommended Posts

DarcyMills
Posted

Hello Emby community,

I'm developing a web application that manages movie and TV shows on my Emby server. I've been facing a persistent issue with the Emby API when trying to create collections.

The Problem

I'm getting a 500 server error with the message "Object reference not set to an instance of an object" when trying to create a collection using the Emby API. I've tried multiple approaches:

  • Using the /emby/Collections endpoint with a POST request
  • Using the /emby/BoxSets endpoint with a POST request
  • Using the /emby/Items endpoint with the CollectionType parameter

All of these attempts result in the same 500 error.

Setup Details

  • Emby Server Version: 4.9.0.46
  • Server OS: Linux
  • Client Application: PHP-based web application
  • Authentication: API key

API Call Example

Here's how I'm trying to create a collection:

POST https://my-emby-server:443/emby/BoxSets?Name=Test%20Collection&api_key=my-api-key

The response is always a 500 error with "Object reference not set to an instance of an object".

What I've Tried

I've tried multiple approaches from various sources, including:

  • The official Emby API documentation
  • The EDCM (Emby Dynamic Collection Manager) Python application on GitHub
  • Various approaches suggested in the forums

I can connect to the Emby server, list libraries, and search for items without any issues - it's only the collection creation that fails.

Questions

  • Is there a working way to create collections via the API in Emby 4.9.0.46?
  • Are there any known issues with collection creation in this version?
  • Does anyone have a working example of creating collections via the API?
  • Is there a specific endpoint or parameter I should be using for my server version?

Any help would be greatly appreciated. I've spent quite some time on this and haven't been able to find a solution that works with my Emby server.

Thank you!

Amything
Posted

Can check my script: https://github.com/jonjonsson/Emby-MDBList-Collection-Creator

def create_collection(self, collection_name, item_ids) -> bool:
        """
        Check if collection exists, creates if not, then adds items to it.
        Must add at least one item when creating collection.

        Args:
            collection_name (str): The name of the collection to be created.
            item_ids (list): A list of item IDs to be added to the collection.

        Returns:
            bool: True if the collection is created successfully, False otherwise.
        """
        if not item_ids:
            print("Can't create collection, no items to add to it.")
            return None

        response = requests.post(
            f"{self.server_url}/Collections?api_key={self.api_key}&IsLocked=true&Name={quote(collection_name)}&Ids={self.__ids_to_str(item_ids)}"
        )

        if response.status_code != 200:
            print(f"Error creating {collection_name}, response: {response}")
            return None

        print(f"Successfully created collection {collection_name}")
        return response.json()["Id"]

 

  • Thanks 1

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