创建 bookingCustomer
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
创建新的 bookingCustomer 对象。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
BookingsAppointment.ReadWrite.All、Bookings.ReadWrite.All、Bookings.Manage.All
委派(个人 Microsoft 帐户)
不支持。
应用程序
不支持。
HTTP 请求
POST /bookingBusinesses/{id}/customers
名称
说明
Authorization
Bearer {code}。 必需。
请求正文
在请求正文中,提供 bookingCustomer 对象的 JSON 表示形式。
响应
如果成功,此方法在响应 201 Created 正文中返回 响应代码和 bookingCustomer 对象。
示例
请求
下面展示了示例请求。
POST https://graph.microsoft.com/beta/bookingBusinesses/Contosolunchdelivery@contoso.onmicrosoft.com/customers
Content-type: application/json
{
"displayName": "Joni Sherman",
"emailAddress": "jonis@relecloud.com",
"addresses": [
{
"postOfficeBox":"",
"street":"4567 Main Street",
"city":"Buffalo",
"state":"NY",
"countryOrRegion":"USA",
"postalCode":"98052",
"type":"home"
},
{
"postOfficeBox":"",
"street":"4570 Main Street",
"city":"Buffalo",
"state":"NY",
"countryOrRegion":"USA",
"postalCode":"98054",
"type":"business"
}
],
"phones": [
{
"number": "206-555-0100",
"type": "home"
},
{
"number": "206-555-0200",
"type": "business"
}
]
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var bookingCustomer = new BookingCustomer
{
DisplayName = "Joni Sherman",
EmailAddress = "jonis@relecloud.com",
Addresses = new List<PhysicalAddress>()
{
new PhysicalAddress
{
PostOfficeBox = "",
Street = "4567 Main Street",
City = "Buffalo",
State = "NY",
CountryOrRegion = "USA",
PostalCode = "98052",
Type = PhysicalAddressType.Home
},
new PhysicalAddress
{
PostOfficeBox = "",
Street = "4570 Main Street",
City = "Buffalo",
State = "NY",
CountryOrRegion = "USA",
PostalCode = "98054",
Type = PhysicalAddressType.Business
}
},
Phones = new List<Phone>()
{
new Phone
{
Number = "206-555-0100",
Type = PhoneType.Home
},
new Phone
{
Number = "206-555-0200",
Type = PhoneType.Business
}
}
};
await graphClient.BookingBusinesses["{bookingBusiness-id}"].Customers
.Request()
.AddAsync(bookingCustomer);
const options = {
authProvider,
};
const client = Client.init(options);
const bookingCustomer = {
displayName: 'Joni Sherman',
emailAddress: 'jonis@relecloud.com',
addresses: [
{
postOfficeBox: '',
street: '4567 Main Street',
city: 'Buffalo',
state: 'NY',
countryOrRegion: 'USA',
postalCode: '98052',
type: 'home'
},
{
postOfficeBox: '',
street: '4570 Main Street',
city: 'Buffalo',
state: 'NY',
countryOrRegion: 'USA',
postalCode: '98054',
type: 'business'
}
],
phones: [
{
number: '206-555-0100',
type: 'home'
},
{
number: '206-555-0200',
type: 'business'
}
]
};
await client.api('/bookingBusinesses/Contosolunchdelivery@contoso.onmicrosoft.com/customers')
.version('beta')
.post(bookingCustomer);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/bookingBusinesses/Contosolunchdelivery@contoso.onmicrosoft.com/customers"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphBookingCustomer *bookingCustomer = [[MSGraphBookingCustomer alloc] init];
[bookingCustomer setDisplayName:@"Joni Sherman"];
[bookingCustomer setEmailAddress:@"jonis@relecloud.com"];
NSMutableArray *addressesList = [[NSMutableArray alloc] init];
MSGraphPhysicalAddress *addresses = [[MSGraphPhysicalAddress alloc] init];
[addresses setPostOfficeBox:@""];
[addresses setStreet:@"4567 Main Street"];
[addresses setCity:@"Buffalo"];
[addresses setState:@"NY"];
[addresses setCountryOrRegion:@"USA"];
[addresses setPostalCode:@"98052"];
[addresses setType: [MSGraphPhysicalAddressType home]];
[addressesList addObject: addresses];
MSGraphPhysicalAddress *addresses = [[MSGraphPhysicalAddress alloc] init];
[addresses setPostOfficeBox:@""];
[addresses setStreet:@"4570 Main Street"];
[addresses setCity:@"Buffalo"];
[addresses setState:@"NY"];
[addresses setCountryOrRegion:@"USA"];
[addresses setPostalCode:@"98054"];
[addresses setType: [MSGraphPhysicalAddressType business]];
[addressesList addObject: addresses];
[bookingCustomer setAddresses:addressesList];
NSMutableArray *phonesList = [[NSMutableArray alloc] init];
MSGraphPhone *phones = [[MSGraphPhone alloc] init];
[phones setNumber:@"206-555-0100"];
[phones setType: [MSGraphPhoneType home]];
[phonesList addObject: phones];
MSGraphPhone *phones = [[MSGraphPhone alloc] init];
[phones setNumber:@"206-555-0200"];
[phones setType: [MSGraphPhoneType business]];
[phonesList addObject: phones];
[bookingCustomer setPhones:phonesList];
NSError *error;
NSData *bookingCustomerData = [bookingCustomer getSerializedDataWithError:&error];
[urlRequest setHTTPBody:bookingCustomerData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
BookingCustomer bookingCustomer = new BookingCustomer();
bookingCustomer.displayName = "Joni Sherman";
bookingCustomer.emailAddress = "jonis@relecloud.com";
LinkedList<PhysicalAddress> addressesList = new LinkedList<PhysicalAddress>();
PhysicalAddress addresses = new PhysicalAddress();
addresses.postOfficeBox = "";
addresses.street = "4567 Main Street";
addresses.city = "Buffalo";
addresses.state = "NY";
addresses.countryOrRegion = "USA";
addresses.postalCode = "98052";
addresses.type = PhysicalAddressType.HOME;
addressesList.add(addresses);
PhysicalAddress addresses1 = new PhysicalAddress();
addresses1.postOfficeBox = "";
addresses1.street = "4570 Main Street";
addresses1.city = "Buffalo";
addresses1.state = "NY";
addresses1.countryOrRegion = "USA";
addresses1.postalCode = "98054";
addresses1.type = PhysicalAddressType.BUSINESS;
addressesList.add(addresses1);
bookingCustomer.addresses = addressesList;
LinkedList<Phone> phonesList = new LinkedList<Phone>();
Phone phones = new Phone();
phones.number = "206-555-0100";
phones.type = PhoneType.HOME;
phonesList.add(phones);
Phone phones1 = new Phone();
phones1.number = "206-555-0200";
phones1.type = PhoneType.BUSINESS;
phonesList.add(phones1);
bookingCustomer.phones = phonesList;
graphClient.bookingBusinesses("Contosolunchdelivery@contoso.onmicrosoft.com").customers()
.buildRequest()
.post(bookingCustomer);
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewBookingCustomer()
displayName := "Joni Sherman"
requestBody.SetDisplayName(&displayName)
emailAddress := "jonis@relecloud.com"
requestBody.SetEmailAddress(&emailAddress)
requestBody.SetAddresses( []PhysicalAddress {
msgraphsdk.NewPhysicalAddress(),
postOfficeBox := ""
SetPostOfficeBox(&postOfficeBox)
street := "4567 Main Street"
SetStreet(&street)
city := "Buffalo"
SetCity(&city)
state := "NY"
SetState(&state)
countryOrRegion := "USA"
SetCountryOrRegion(&countryOrRegion)
postalCode := "98052"
SetPostalCode(&postalCode)
type := "home"
SetType(&type)
msgraphsdk.NewPhysicalAddress(),
postOfficeBox := ""
SetPostOfficeBox(&postOfficeBox)
street := "4570 Main Street"
SetStreet(&street)
city := "Buffalo"
SetCity(&city)
state := "NY"
SetState(&state)
countryOrRegion := "USA"
SetCountryOrRegion(&countryOrRegion)
postalCode := "98054"
SetPostalCode(&postalCode)
type := "business"
SetType(&type)
}
requestBody.SetPhones( []Phone {
msgraphsdk.NewPhone(),
number := "206-555-0100"
SetNumber(&number)
type := "home"
SetType(&type)
msgraphsdk.NewPhone(),
number := "206-555-0200"
SetNumber(&number)
type := "business"
SetType(&type)
}
bookingBusinessId := "bookingBusiness-id"
result, err := graphClient.BookingBusinessesById(&bookingBusinessId).Customers().Post(requestBody)
Import-Module Microsoft.Graph.Bookings
$params = @{
DisplayName = "Joni Sherman"
EmailAddress = "jonis@relecloud.com"
Addresses = @(
@{
PostOfficeBox = ""
Street = "4567 Main Street"
City = "Buffalo"
State = "NY"
CountryOrRegion = "USA"
PostalCode = "98052"
Type = "home"
}
@{
PostOfficeBox = ""
Street = "4570 Main Street"
City = "Buffalo"
State = "NY"
CountryOrRegion = "USA"
PostalCode = "98054"
Type = "business"
}
)
Phones = @(
@{
Number = "206-555-0100"
Type = "home"
}
@{
Number = "206-555-0200"
Type = "business"
}
)
}
New-MgBookingBusinessCustomer -BookingBusinessId $bookingBusinessId -BodyParameter $params
响应
下面展示了示例响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#bookingBusinesses('Contosolunchdelivery%40contoso.onmicrosoft.com')/customers/$entity",
"id": "36038f36-634e-44e4-9415-d7d59c2347aa",
"displayName": "Joni Sherman",
"emailAddress": "jonis@relecloud.com",
"addresses": [
{
"postOfficeBox":"",
"street":"4567 Main Street",
"city":"Buffalo",
"state":"NY",
"countryOrRegion":"USA",
"postalCode":"98052",
"type":"home"
},
{
"postOfficeBox":"",
"street":"4570 Main Street",
"city":"Buffalo",
"state":"NY",
"countryOrRegion":"USA",
"postalCode":"98054",
"type":"business"
}
],
"phones": [
{
"number": "206-555-0100",
"type": "home"
},
{
"number": "206-555-0200",
"type": "business"
}
]
}