Create bookingService
8/15/2019
4 minutes to read
In this article
Important
APIs under the /beta
version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported.
Create a new bookingService for the specified bookingbusiness .
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions .
Permission type
Permissions (from least to most privileged)
Delegated (work or school account)
Bookings.ReadWrite.All, Bookings.Manage.All
Delegated (personal Microsoft account)
Not supported.
Application
Not supported.
HTTP request
POST /bookingBusinesses/{id}/services
Name
Description
Authorization
Bearer {code}
Request body
In the request body, supply a JSON representation of bookingService object.
Response
If successful, this method returns 201, Created
response code and bookingService object in the response body.
Example
Request
The following is an example of the request.
POST https://graph.microsoft.com/beta/bookingBusinesses/Contosolunchdelivery@M365B489948.onmicrosoft.com/services
Content-type: application/json
{
"@odata.type":"#microsoft.graph.bookingService",
"defaultDuration":"PT1H30M",
"defaultLocation":{
"@odata.type":"#microsoft.graph.location",
"address":{
"@odata.type":"#microsoft.graph.physicalAddress",
"city":"Buffalo",
"countryOrRegion":"USA",
"postalCode":"98052",
"postOfficeBox":null,
"state":"NY",
"street":"4567 First Street",
"type@odata.type":"#microsoft.graph.physicalAddressType",
"type":null
},
"coordinates":null,
"displayName":"Contoso Lunch Delivery",
"locationEmailAddress":null,
"locationType@odata.type":"#microsoft.graph.locationType",
"locationType":null,
"locationUri":null,
"uniqueId":null,
"uniqueIdType@odata.type":"#microsoft.graph.locationUniqueIdType",
"uniqueIdType":null
},
"defaultPrice":10.0,
"defaultPriceType@odata.type":"#microsoft.graph.bookingPriceType",
"defaultPriceType":"fixedPrice",
"defaultReminders@odata.type":"#Collection(microsoft.graph.bookingReminder)",
"defaultReminders":[
{
"@odata.type":"#microsoft.graph.bookingReminder",
"message":"Please be reminded that this service is tomorrow.",
"offset":"P1D",
"recipients@odata.type":"#microsoft.graph.bookingReminderRecipients",
"recipients":"allAttendees"
}
],
"description":"Individual bento box lunch delivery",
"displayName":"Bento",
"isHiddenFromCustomers":false,
"notes":"Home-cooked special",
"postBuffer":"PT10M",
"preBuffer":"PT5M",
"schedulingPolicy":{
"@odata.type":"#microsoft.graph.bookingSchedulingPolicy",
"allowStaffSelection":true,
"maximumAdvance":"P10D",
"minimumLeadTime":"PT10H",
"sendConfirmationsToOwner":true,
"timeSlotInterval":"PT1H"
},
"staffMemberIds@odata.type":"#Collection(String)",
"staffMemberIds":[
"d90d1e8c-5cfe-48cf-a2d5-966267375b6a",
"2f5f8794-0b29-45b5-b56a-2eb5ff7aa880"
]
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var bookingService = new BookingService
{
DefaultDuration = "PT1H30M",
DefaultLocation = new Location
{
Address = new PhysicalAddress
{
City = "Buffalo",
CountryOrRegion = "USA",
PostalCode = "98052",
PostOfficeBox = null,
State = "NY",
Street = "4567 First Street",
AdditionalData = new Dictionary<string, object>()
{
{"type@odata.type","#microsoft.graph.physicalAddressType"}
},
Type = null
},
Coordinates = null,
DisplayName = "Contoso Lunch Delivery",
LocationEmailAddress = null,
AdditionalData = new Dictionary<string, object>()
{
{"uniqueIdType@odata.type","#microsoft.graph.locationUniqueIdType"},
{"locationType@odata.type","#microsoft.graph.locationType"}
},
LocationType = null,
LocationUri = null,
UniqueId = null,
UniqueIdType = null
},
DefaultPrice = 10,
AdditionalData = new Dictionary<string, object>()
{
{"staffMemberIds@odata.type","#Collection(String)"},
{"defaultReminders@odata.type","#Collection(microsoft.graph.bookingReminder)"},
{"defaultPriceType@odata.type","#microsoft.graph.bookingPriceType"}
},
DefaultPriceType = BookingPriceType.FixedPrice,
DefaultReminders = new List<BookingReminder>()
{
new BookingReminder
{
Message = "Please be reminded that this service is tomorrow.",
Offset = "P1D",
AdditionalData = new Dictionary<string, object>()
{
{"recipients@odata.type","#microsoft.graph.bookingReminderRecipients"}
},
Recipients = BookingReminderRecipients.AllAttendees
}
},
Description = "Individual bento box lunch delivery",
DisplayName = "Bento",
IsHiddenFromCustomers = false,
Notes = "Home-cooked special",
PostBuffer = "PT10M",
PreBuffer = "PT5M",
SchedulingPolicy = new BookingSchedulingPolicy
{
AllowStaffSelection = true,
MaximumAdvance = "P10D",
MinimumLeadTime = "PT10H",
SendConfirmationsToOwner = true,
TimeSlotInterval = "PT1H"
},
StaffMemberIds = new List<String>()
{
"d90d1e8c-5cfe-48cf-a2d5-966267375b6a",
"2f5f8794-0b29-45b5-b56a-2eb5ff7aa880"
}
};
await graphClient.BookingBusinesses["Contosolunchdelivery@M365B489948.onmicrosoft.com"].Services
.Request()
.AddAsync(bookingService);
Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
const options = {
authProvider,
};
const client = Client.init(options);
const bookingService = {
@odata.type:"#microsoft.graph.bookingService",
defaultDuration:"PT1H30M",
defaultLocation:{
@odata.type:"#microsoft.graph.location",
address:{
@odata.type:"#microsoft.graph.physicalAddress",
city:"Buffalo",
countryOrRegion:"USA",
postalCode:"98052",
postOfficeBox:null,
state:"NY",
street:"4567 First Street",
type@odata.type:"#microsoft.graph.physicalAddressType",
type:null
},
coordinates:null,
displayName:"Contoso Lunch Delivery",
locationEmailAddress:null,
locationType@odata.type:"#microsoft.graph.locationType",
locationType:null,
locationUri:null,
uniqueId:null,
uniqueIdType@odata.type:"#microsoft.graph.locationUniqueIdType",
uniqueIdType:null
},
defaultPrice:10.0,
defaultPriceType@odata.type:"#microsoft.graph.bookingPriceType",
defaultPriceType:"fixedPrice",
defaultReminders@odata.type:"#Collection(microsoft.graph.bookingReminder)",
defaultReminders:[
{
@odata.type:"#microsoft.graph.bookingReminder",
message:"Please be reminded that this service is tomorrow.",
offset:"P1D",
recipients@odata.type:"#microsoft.graph.bookingReminderRecipients",
recipients:"allAttendees"
}
],
description:"Individual bento box lunch delivery",
displayName:"Bento",
isHiddenFromCustomers:false,
notes:"Home-cooked special",
postBuffer:"PT10M",
preBuffer:"PT5M",
schedulingPolicy:{
@odata.type:"#microsoft.graph.bookingSchedulingPolicy",
allowStaffSelection:true,
maximumAdvance:"P10D",
minimumLeadTime:"PT10H",
sendConfirmationsToOwner:true,
timeSlotInterval:"PT1H"
},
staffMemberIds@odata.type:"#Collection(String)",
staffMemberIds:[
"d90d1e8c-5cfe-48cf-a2d5-966267375b6a",
"2f5f8794-0b29-45b5-b56a-2eb5ff7aa880"
]
};
let res = await client.api('/bookingBusinesses/Contosolunchdelivery@M365B489948.onmicrosoft.com/services')
.version('beta')
.post(bookingService);
Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/bookingBusinesses/Contosolunchdelivery@M365B489948.onmicrosoft.com/services"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphBookingService *bookingService = [[MSGraphBookingService alloc] init];
[bookingService setDefaultDuration:@"PT1H30M"];
MSGraphLocation *defaultLocation = [[MSGraphLocation alloc] init];
MSGraphPhysicalAddress *address = [[MSGraphPhysicalAddress alloc] init];
[address setCity:@"Buffalo"];
[address setCountryOrRegion:@"USA"];
[address setPostalCode:@"98052"];
[address setPostOfficeBox: null];
[address setState:@"NY"];
[address setStreet:@"4567 First Street"];
[address setType: null];
[defaultLocation setAddress:address];
[defaultLocation setCoordinates: null];
[defaultLocation setDisplayName:@"Contoso Lunch Delivery"];
[defaultLocation setLocationEmailAddress: null];
[defaultLocation setLocationType: null];
[defaultLocation setLocationUri: null];
[defaultLocation setUniqueId: null];
[defaultLocation setUniqueIdType: null];
[bookingService setDefaultLocation:defaultLocation];
[bookingService setDefaultPrice: 10.0];
[bookingService setDefaultPriceType: [MSGraphBookingPriceType fixedPrice]];
NSMutableArray *defaultRemindersList = [[NSMutableArray alloc] init];
MSGraphBookingReminder *defaultReminders = [[MSGraphBookingReminder alloc] init];
[defaultReminders setMessage:@"Please be reminded that this service is tomorrow."];
[defaultReminders setOffset:@"P1D"];
[defaultReminders setRecipients: [MSGraphBookingReminderRecipients allAttendees]];
[defaultRemindersList addObject: defaultReminders];
[bookingService setDefaultReminders:defaultRemindersList];
[bookingService setDescription:@"Individual bento box lunch delivery"];
[bookingService setDisplayName:@"Bento"];
[bookingService setIsHiddenFromCustomers: false];
[bookingService setNotes:@"Home-cooked special"];
[bookingService setPostBuffer:@"PT10M"];
[bookingService setPreBuffer:@"PT5M"];
MSGraphBookingSchedulingPolicy *schedulingPolicy = [[MSGraphBookingSchedulingPolicy alloc] init];
[schedulingPolicy setAllowStaffSelection: true];
[schedulingPolicy setMaximumAdvance:@"P10D"];
[schedulingPolicy setMinimumLeadTime:@"PT10H"];
[schedulingPolicy setSendConfirmationsToOwner: true];
[schedulingPolicy setTimeSlotInterval:@"PT1H"];
[bookingService setSchedulingPolicy:schedulingPolicy];
NSMutableArray *staffMemberIdsList = [[NSMutableArray alloc] init];
[staffMemberIdsList addObject: @"d90d1e8c-5cfe-48cf-a2d5-966267375b6a"];
[staffMemberIdsList addObject: @"2f5f8794-0b29-45b5-b56a-2eb5ff7aa880"];
[bookingService setStaffMemberIds:staffMemberIdsList];
NSError *error;
NSData *bookingServiceData = [bookingService getSerializedDataWithError:&error];
[urlRequest setHTTPBody:bookingServiceData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
Read the SDK documentation for details on how to add the SDK to your project and create an authProvider instance.
In the request body, supply a JSON representation of bookingService object.
Response
The following is an example of the response. Note: The response object shown here may be truncated for brevity. All of the properties will be returned from an actual call.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#bookingBusinesses('Contosolunchdelivery%40M365B489948.onmicrosoft.com')/services/$entity",
"id": "57da6774-a087-4d69-b0e6-6fb82c339976",
"displayName": "Bento",
"defaultDuration": "PT1H30M",
"defaultPrice": 10,
"defaultPriceType": "fixedPrice",
"description": "Individual bento box lunch delivery",
"isHiddenFromCustomers": false,
"notes": "Home-cooked special",
"preBuffer": "PT5M",
"postBuffer": "PT10M",
"staffMemberIds": [],
"defaultLocation": {
"displayName": "Contoso Lunch Delivery",
"locationEmailAddress": null,
"locationUri": "",
"locationType": null,
"uniqueId": null,
"uniqueIdType": null,
"address": {
"type": "home",
"postOfficeBox": "",
"street": "4567 First Street",
"city": "Buffalo",
"state": "NY",
"countryOrRegion": "USA",
"postalCode": "98052"
},
"coordinates": {
"altitude": null,
"latitude": null,
"longitude": null,
"accuracy": null,
"altitudeAccuracy": null
}
},
"defaultReminders": [
{
"offset": "P1D",
"recipients": "allAttendees",
"message": "Please be reminded that this service is tomorrow."
}
],
"schedulingPolicy": {
"timeSlotInterval": "PT1H",
"minimumLeadTime": "PT10H",
"maximumAdvance": "P10D",
"sendConfirmationsToOwner": true,
"allowStaffSelection": true
}
}