Tuesday, April 23, 2024
HomePowershellMicrosoft Bookings API find out how to

Microsoft Bookings API find out how to


On the subject of Microsoft Bookings and automation the documentation about API could be discovered right here, there’s additionally a PowerShell module, at first I didn’t understand how to connect with Bookings API and I’ve created a reserving mailbox with Trade On-line PowerShell with New-SchedulingMailbox BUT! don’t do it.

This New-SchedulingMailbox shouldn’t be a great way to create it – later I had some points after I was attempting to do modifications on the reserving useful resource utilizing API, see right here and right here.

Ther code to connect with the API is:

$TenantID       = "<tenant>.onmicrosoft.com"
$AccountName    = "BookingAutomation@area.com"
$Password       = '<bookingautomationpassword>'
$ClientId       = "XXXXXXX-XXX-XXX-XXX-XXXXXXXXXXXXX" # "Reserving-GraphAPI" software ID</bookingautomationpassword></tenant>

# Constants - Endpoints
$AzureResourceURI = "https://login.microsoftonline.com/$($tenantID)/oauth2/token"
$ResourceID  = "https://graph.microsoft.com"

# Assemble the Physique for the POST
$Physique = "grant_type=password"`
         +"&amp;username=" +$Accountname `
         +"&amp;client_id=" +$clientId `
         +"&amp;password=" +$Password `
         +"&amp;useful resource=" +[system.uri]::EscapeDataString($ResourceID)

Write-Host "Getting the authorization token"

# The outcome ought to include a token to be used with Graph
$Response = Invoke-WebRequest -Uri $AzureResourceURI -Technique POST -Physique $Physique
$ResponseJSON = $Response|ConvertFrom-Json

After connectig you should use this to create a Reserving with PowerShell module:

$NewBookingParams = @{
    DisplayName = "FirstBooking"
    BusinessType = "IT Companies"
    WebSiteUrl = "https://www.area.com"
    SchedulingPolicy = @{
        AllowStaffSelection = $false
        MaximumAdvance = "P30D"
        MinimumLeadTime = "P1D"
    }
}
$NewBooking = New-MgBookingBusiness @NewBookingParams

Including customers is straightforward, so I’ll simply share a means I’m making a service:

$NewServiceParams = @{
    BookingBusinessId = $PrimarySmtpAddress
    DefaultDuration = "00:15:00" # quarter-hour period
    IsLocationOnline = $true
    MaximumAttendeesCount = 10
    StaffMemberIds = $StaffMemberId #A workers member ID to be assigned to the service
    DisplayName = "15 min name"
    DefaultReminders = @{
        Message = "Only a fast reminder that your service is comming up quickly."
        Offset = "P1D"
        #0 - All recipients, 2 - Buyer, 1 - Workers
        Recipients = "2"
    }
}

New-MgBookingBusinessService @NewServiceParams



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments