Skip to content

Unable to set profile picture when creating a user #13

@cr1g

Description

@cr1g

Simply put, the last line in the code below fails with the exception: TypeError: Object of type bytes is not JSON serializable.

from io import BytesIO

from sendbird_platform_sdk.api import user_api
from sendbird_platform_sdk.model.create_user_data import CreateUserData

with open("profile_picture.jpg", "rb") as profile_picture:
    profile_picture_stream = profile_picture.read()

api_instance = user_api.UserApi(api_client)
create_user_data = CreateUserData(
    user_id="random_guid",
    nickname="example_nickname",
    profile_url="",
    profile_file=BytesIO(profile_picture_stream),
    issue_access_token=True,
)
api_instance.create_user(
    api_token="MY_API_TOKEN", create_user_data=create_user_data
)

The full exception details can be found here: full_exception_details.txt

EDIT: Added imports.

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