[Python] How to set names in a new bookingCustomer (Microsoft Bookings)

Discussão em 'Python' iniciado por Stack, Março 9, 2025.

  1. Stack

    Stack Membro Participativo

    the documentation shows how to set the display_name but not the first and last names!

    [​IMG]

    from what I can find, setting the first and last name is only possible through the web interface, which is not practical since I have many clients to update, and I want to write a python script to automate this task!

    [​IMG]

    this is a code example:

    from msgraph import GraphServiceClient
    from msgraph.generated.models.booking_customer import BookingCustomer
    from msgraph.generated.models.physical_address import PhysicalAddress
    from msgraph.generated.models.phone import Phone
    from msgraph.generated.models.phone_type import PhoneType

    graph_client = self.app_client
    request_body = BookingCustomer(
    odata_type = "#microsoft.graph.bookingCustomer",
    display_name = "Joni Sherman",
    email_address = "jonis@relecloud.com",
    addresses = [
    PhysicalAddress(
    street = "4567 Main Street",
    city = "Buffalo",
    state = "NY",
    country_or_region = "USA",
    postal_code = "98052",
    ),
    ],
    phones = [
    Phone(
    number = "206-555-0100",
    type = PhoneType.Mobile,
    )
    ],
    )

    try:
    result = await graph_client.solutions.booking_businesses.by_booking_business_id(BOOKING_BUSINESS_ID).customers.post(request_body)
    return result
    except APIError as e:
    print(f'Error: {e}')


    Note that I tried adding firstName and lastName but it doesn't work!

    Continue reading...

Compartilhe esta Página