Skip to content

Can't serialize value type 'UUID' #161

@howieweiner

Description

@howieweiner

Hi. I've just started using the xero-python SDK (v 6.3.0) to retrieve Invoices. There appears to be an issue in the client when serializing UUID fields

This code:

response = accounting_api.get_invoice(XERO_TENANT_ID, invoice_id)

throws a ValueError `Can't serialize value type 'UUID' when attempting to
serialize the model.

I've resolved this issue by patching the serializer based on this suggestion in Issue #93

@serialize_model.register(UUID)
def serialize_uuid_model(model):
    """Serializes api model into an json serializable object.

    :param model: BaseModel instance to serialize
    :return: serialized object
    """
    return model.hex
    ```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions