创建 bookingBusiness
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
在租户中创建新的Microsoft Bookings业务。
这是设置 Bookings 业务的第一步,你必须在其中指定业务显示名称。 可以包含其他信息,例如业务地址、网站地址和计划策略,或稍后通过更新 bookingBusiness 来设置该信息。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限。
| 权限类型 |
权限(从最低特权到最高特权) |
| 委派(工作或学校帐户) |
Bookings.Manage.All |
| 委派(个人 Microsoft 帐户) |
不支持。 |
| Application |
不支持。 |
HTTP 请求
POST /bookingBusinesses
| 名称 |
说明 |
| Authorization |
Bearer {code} |
请求正文
在请求正文中,提供 bookingBusiness 对象的 JSON 表示形式。
响应
如果成功,此方法在响应正文中返回 201, Created 响应代码和 bookingBusiness 对象。
示例
请求
下面展示了示例请求。
POST https://graph.microsoft.com/beta/bookingBusinesses
Content-type: application/json
{
"displayName":"Fourth Coffee",
"address":{
"postOfficeBox":"P.O. Box 123",
"street":"4567 Main Street",
"city":"Buffalo",
"state":"NY",
"countryOrRegion":"USA",
"postalCode":"98052"
},
"phone":"206-555-0100",
"email":"manager@fourthcoffee.com",
"webSiteUrl":"https://www.fourthcoffee.com",
"defaultCurrencyIso":"USD"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var bookingBusiness = new BookingBusiness
{
DisplayName = "Fourth Coffee",
Address = new PhysicalAddress
{
PostOfficeBox = "P.O. Box 123",
Street = "4567 Main Street",
City = "Buffalo",
State = "NY",
CountryOrRegion = "USA",
PostalCode = "98052"
},
Phone = "206-555-0100",
Email = "manager@fourthcoffee.com",
WebSiteUrl = "https://www.fourthcoffee.com",
DefaultCurrencyIso = "USD"
};
await graphClient.BookingBusinesses
.Request()
.AddAsync(bookingBusiness);
const options = {
authProvider,
};
const client = Client.init(options);
const bookingBusiness = {
displayName: 'Fourth Coffee',
address: {
postOfficeBox: 'P.O. Box 123',
street: '4567 Main Street',
city: 'Buffalo',
state: 'NY',
countryOrRegion: 'USA',
postalCode: '98052'
},
phone: '206-555-0100',
email: 'manager@fourthcoffee.com',
webSiteUrl: 'https://www.fourthcoffee.com',
defaultCurrencyIso: 'USD'
};
await client.api('/bookingBusinesses')
.version('beta')
.post(bookingBusiness);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/bookingBusinesses"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphBookingBusiness *bookingBusiness = [[MSGraphBookingBusiness alloc] init];
[bookingBusiness setDisplayName:@"Fourth Coffee"];
MSGraphPhysicalAddress *address = [[MSGraphPhysicalAddress alloc] init];
[address setType: [MSGraphPhysicalAddressType unknown]];
[address setPostOfficeBox:@"P.O. Box 123"];
[address setStreet:@"4567 Main Street"];
[address setCity:@"Buffalo"];
[address setState:@"NY"];
[address setCountryOrRegion:@"USA"];
[address setPostalCode:@"98052"];
[bookingBusiness setAddress:address];
[bookingBusiness setPhone:@"206-555-0100"];
[bookingBusiness setEmail:@"manager@fourthcoffee.com"];
[bookingBusiness setWebSiteUrl:@"https://www.fourthcoffee.com"];
[bookingBusiness setDefaultCurrencyIso:@"USD"];
NSError *error;
NSData *bookingBusinessData = [bookingBusiness getSerializedDataWithError:&error];
[urlRequest setHTTPBody:bookingBusinessData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
BookingBusiness bookingBusiness = new BookingBusiness();
bookingBusiness.displayName = "Fourth Coffee";
PhysicalAddress address = new PhysicalAddress();
address.postOfficeBox = "P.O. Box 123";
address.street = "4567 Main Street";
address.city = "Buffalo";
address.state = "NY";
address.countryOrRegion = "USA";
address.postalCode = "98052";
bookingBusiness.address = address;
bookingBusiness.phone = "206-555-0100";
bookingBusiness.email = "manager@fourthcoffee.com";
bookingBusiness.webSiteUrl = "https://www.fourthcoffee.com";
bookingBusiness.defaultCurrencyIso = "USD";
graphClient.bookingBusinesses()
.buildRequest()
.post(bookingBusiness);
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewBookingBusiness()
displayName := "Fourth Coffee"
requestBody.SetDisplayName(&displayName)
address := msgraphsdk.NewPhysicalAddress()
requestBody.SetAddress(address)
postOfficeBox := "P.O. Box 123"
address.SetPostOfficeBox(&postOfficeBox)
street := "4567 Main Street"
address.SetStreet(&street)
city := "Buffalo"
address.SetCity(&city)
state := "NY"
address.SetState(&state)
countryOrRegion := "USA"
address.SetCountryOrRegion(&countryOrRegion)
postalCode := "98052"
address.SetPostalCode(&postalCode)
phone := "206-555-0100"
requestBody.SetPhone(&phone)
email := "manager@fourthcoffee.com"
requestBody.SetEmail(&email)
webSiteUrl := "https://www.fourthcoffee.com"
requestBody.SetWebSiteUrl(&webSiteUrl)
defaultCurrencyIso := "USD"
requestBody.SetDefaultCurrencyIso(&defaultCurrencyIso)
result, err := graphClient.BookingBusinesses().Post(requestBody)
Import-Module Microsoft.Graph.Bookings
$params = @{
DisplayName = "Fourth Coffee"
Address = @{
PostOfficeBox = "P.O. Box 123"
Street = "4567 Main Street"
City = "Buffalo"
State = "NY"
CountryOrRegion = "USA"
PostalCode = "98052"
}
Phone = "206-555-0100"
Email = "manager@fourthcoffee.com"
WebSiteUrl = "https://www.fourthcoffee.com"
DefaultCurrencyIso = "USD"
}
New-MgBookingBusiness -BodyParameter $params
在请求正文中,提供 bookingBusiness 对象的 JSON 表示形式。
响应
这是一个示例响应。注意:为提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/beta/$metadata#bookingBusinesses/$entity",
"id":"fourthcoffee@contoso.onmicrosoft.com",
"displayName":"Fourth Coffee",
"businessType":"",
"phone":"206-555-0100",
"email":"manager@fourthcoffee.com",
"webSiteUrl":"https://www.fourthcoffee.com",
"defaultCurrencyIso":"USD",
"isPublished":false,
"publicUrl":null,
"address":{
"postOfficeBox":"P.O. Box 123",
"street":"4567 Main Street",
"city":"Buffalo",
"state":"NY",
"countryOrRegion":"USA",
"postalCode":"98052"
},
"businessHours":[
{
"day":"monday",
"timeSlots":[
{
"start":"08:00:00.0000000",
"end":"17:00:00.0000000"
}
]
},
{
"day":"tuesday",
"timeSlots":[
{
"start":"08:00:00.0000000",
"end":"17:00:00.0000000"
}
]
},
{
"day":"wednesday",
"timeSlots":[
{
"start":"08:00:00.0000000",
"end":"17:00:00.0000000"
}
]
},
{
"day":"thursday",
"timeSlots":[
{
"start":"08:00:00.0000000",
"end":"17:00:00.0000000"
}
]
},
{
"day":"friday",
"timeSlots":[
{
"start":"08:00:00.0000000",
"end":"17:00:00.0000000"
}
]
},
{
"day":"saturday",
"timeSlots":[
]
},
{
"day":"sunday",
"timeSlots":[
]
}
],
"languageTag":"en-US",
"schedulingPolicy":{
"timeSlotInterval":"PT30M",
"minimumLeadTime":"P1D",
"maximumAdvance":"P365D",
"sendConfirmationsToOwner":true,
"allowStaffSelection":true
}
}