{"id":1554,"library":"microsoft-kiota-serialization-multipart","title":"Microsoft Kiota Multipart Serialization","description":"This library provides core abstractions and implementation for serializing and deserializing multipart content within Microsoft Kiota generated Python clients. It's part of the broader Kiota ecosystem for building API clients and is currently at version 1.10.1, with a regular release cadence synchronized with other Kiota Python packages. It supports Python versions >=3.10 and <4.0.","status":"active","version":"1.10.1","language":"en","source_language":"en","source_url":"https://github.com/microsoft/kiota-python","tags":["serialization","multipart","kiota","microsoft","api-client","http"],"install":[{"cmd":"pip install microsoft-kiota-serialization-multipart","lang":"bash","label":"Install library"}],"dependencies":[{"reason":"Provides core interfaces and models required by all Kiota components, including serialization, such as `Parsable`, `SerializationWriter`, and `ParseNode`.","package":"microsoft-kiota-abstractions","optional":false}],"imports":[{"symbol":"MultipartSerializationWriterFactory","correct":"from microsoft_kiota_serialization_multipart import MultipartSerializationWriterFactory"},{"symbol":"MultipartParseNodeFactory","correct":"from microsoft_kiota_serialization_multipart import MultipartParseNodeFactory"}],"quickstart":{"code":"from microsoft_kiota_abstractions.serialization import (\n    register_default_deserializer,\n    register_default_serializer,\n    SerializationWriterFactoryRegistry,\n    ParseNodeFactoryRegistry\n)\nfrom microsoft_kiota_serialization_multipart import (\n    MultipartSerializationWriterFactory,\n    MultipartParseNodeFactory\n)\n\n# Initialize and register the multipart serialization and deserialization factories.\n# This makes them available to Kiota's internal machinery when\n# 'multipart/form-data' content type is encountered.\nmulipart_serializer_factory = MultipartSerializationWriterFactory()\nmulipart_parser_factory = MultipartParseNodeFactory()\n\nregister_default_serializer(mulipart_serializer_factory)\nregister_default_deserializer(mulipart_parser_factory)\n\nprint(\"Microsoft Kiota Multipart Serialization and Deserialization factories registered.\")\n\n# You can now retrieve them from the global registry (e.g., for custom HTTP client setups)\n# The Kiota generated clients typically handle this registration automatically.\nwriter_factory = SerializationWriterFactoryRegistry.get_default_instance().get_serialization_writer_factory(\"multipart/form-data\")\nparser_factory = ParseNodeFactoryRegistry.get_default_instance().get_parse_node_factory(\"multipart/form-data\")\n\nif writer_factory and parser_factory:\n    print(\"\\nSuccessfully retrieved Multipart factories from the global registry:\")\n    print(f\"- Serialization Writer Factory: {writer_factory}\")\n    print(f\"- Parse Node Factory: {parser_factory}\")\n    print(\"\\nThese factories enable Kiota clients to handle 'multipart/form-data' requests and responses.\")\nelse:\n    print(\"\\nError: Could not retrieve Multipart factories from the global registry.\")\n\n# To perform actual serialization/deserialization, you would typically use a\n# Kiota-generated client or directly interact with the writer/parser with file streams\n# or form data.","lang":"python","description":"This quickstart demonstrates how to initialize and register the `MultipartSerializationWriterFactory` and `MultipartParseNodeFactory` with Kiota's global registries. This registration is crucial for Kiota-generated API clients to automatically handle `multipart/form-data` content types for both sending requests and parsing responses. While direct usage of writers/parsers involves streams, this example focuses on their integration within the Kiota framework."},"warnings":[{"fix":"Upgrade your Python environment to 3.10 or newer. Alternatively, if Python 3.9 is required, pin the library version to `<1.10.0` (e.g., `microsoft-kiota-serialization-multipart<1.10.0`).","message":"Version 1.10.0 and later dropped official support for Python 3.9. Users attempting to install or run with Python 3.9 will encounter `Requires-Python` metadata errors or unexpected runtime behavior.","severity":"breaking","affected_versions":">=1.10.0"},{"fix":"Verify that `microsoft-kiota-abstractions` is included in your project's `requirements.txt` or `pyproject.toml`. For `pip`, it's usually installed automatically as a transitive dependency.","message":"This package relies heavily on core interfaces defined in `microsoft-kiota-abstractions`. If you manually manage your dependencies, ensure `microsoft-kiota-abstractions` is explicitly installed alongside `microsoft-kiota-serialization-multipart` to avoid `ModuleNotFoundError` or `TypeError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"When constructing multipart content, explicitly write each field or file as a separate part using specific methods like `write_str_value`, `write_bool_value`, or `write_byte_array_value` for file streams. Avoid relying solely on `write_object_value` for the entire payload unless you understand its specific implications for multipart content.","message":"While `MultipartSerializationWriter` supports `write_object_value`, multipart content is fundamentally different from single-body formats like JSON or XML. It's designed for sending data as distinct parts (e.g., form fields, files). Direct serialization of a complex `Parsable` object might not produce the desired single-body multipart output as expected in other formats.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}