You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Python脚本为Microsoft Bookings的bookingCustomer设置姓和名?

如何通过Graph API批量设置Booking客户的姓和名?
  • 查阅Microsoft Graph API的Booking客户创建文档,发现仅说明如何设置display_name字段,未提及firstName和lastName的设置方法
  • 当前仅能通过网页界面手动设置客户的姓和名,但需要批量更新大量客户,希望用Python脚本实现自动化操作
  • 尝试在BookingCustomer请求体中直接添加firstName和lastName字段,执行后未生效

界面差异示例

有无姓和名的客户差异

网页设置界面

更新bookingCustomer的UI界面

现有Python代码

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}')

注:尝试在request_body中添加firstName="Joni"和lastName="Sherman"字段,执行脚本后客户的姓和名并未被设置。

内容的提问来源于stack exchange,提问作者Stoufa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 21:32:40