VBAuth — Get Booking Appointments #
Overview #
Retrieves Microsoft Bookings appointments for a specified Bookings business calendar within a two-day rolling window from today. Results are filtered client-side to genuine Bookings entries and formatted for display.
Azure permission required: BookingsAppointment.ReadWrite.All
Note: The Microsoft Graph API does not provide a read-only scope for Bookings appointments.
BookingsAppointment.ReadWrite.Allis the minimum permission available and is required even when only reading data. This is a Microsoft Graph API limitation, not a VBAuth restriction.
Known Microsoft Graph API Limitations #
The Bookings appointments endpoint has several significant constraints that are outside VBAuth’s control. These are documented Microsoft Graph API issues and are noted here so you can set accurate expectations with end users.
Server-side filtering is not supported.
The /appointments endpoint accepts $filter in the URL but filtering by appointment properties
such as customerName, serviceName, or staffMemberIds either returns a BadRequest error
or silently returns incorrect results. This is a confirmed Microsoft Graph API issue. All
filtering in this implementation is therefore done client-side after the full response is received.
The calendarView endpoint does not support $filter.
GET /solutions/bookingBusinesses/{id}/calendarView officially supports only $count and
$expand query parameters. Attempts to use $filter on this endpoint return errors or produce
unreliable results. This implementation uses the /appointments endpoint instead, with
startDateTime range parameters.
Non-Bookings calendar entries may be returned.
The Graph API returns all entries on the Bookings business calendar, including internal calendar
blocks and other non-appointment entries that do not represent genuine customer bookings. These
are filtered out client-side by checking that customerName is not empty or null. Entries
without a customer name are silently skipped.
Paging (@odata.nextLink) is supported in the code but rarely triggered.
The implementation follows @odata.nextLink for completeness, but in practice the Bookings
API rarely pages appointment collections within a short date range.
VBAuth Admin Table Configuration #
| Column Name | Required Value / Example | Notes |
|---|---|---|
| AppID | 6 | Identifies this feature’s configuration record |
| ActionName | VBAuth – List Bookings | Display name — any value acceptable |
| ClientID | (your App Client ID) | GUID from Azure App Registration Overview blade |
| TenantID | (your Tenant ID) | GUID from Azure App Registration Overview blade |
| ObjectID | (your Object ID) | Set by PopulateMissingObjectIDs |
| ScopeClaims | BookingsAppointment.ReadWrite.All | Comma-separated Graph scopes |
| Verb | GET | HTTP method |
| URLPart1 | https://graph.microsoft.com/v1.0/solutions/bookingBusinesses/ | Base endpoint — Bookings business SMTP address appended at runtime |
| URLParameter1 | Bookings calendar SMTP address | e.g. mybusiness@contoso.com — substituted at runtime |
| URLPart2 | /appointments | Appended after URLParameter1 |
| URLParameter2 | NO VALUE REQUIRED | Not used |
| URLPart3 | NO VALUE REQUIRED | Not used |
| WaitForLogin | 60 | Seconds — NB MSXML2 timeout parameters are in milliseconds |
Azure setup reminder: After creating the App Registration, copy the App (Client) ID and Directory (Tenant) ID from the Overview blade before navigating away.
Azure App Registration #
Create a new App Registration in Azure Entra ID (portal.azure.com):
- Go to Microsoft Entra ID → App registrations → New registration
- Name: e.g.
VBAuth - Bookings - Supported account types: Single tenant
- Redirect URI: Platform = Public client/native, URI =
http://localhost - Click Register
- Copy the Application (Client) ID and Directory (Tenant) ID from the Overview blade
- Go to API permissions → Add a permission → Microsoft Graph → Delegated permissions
- Add:
BookingsAppointment.ReadWrite.All - Click Grant admin consent
How It Works #
GetBookingAppointments follows the standard VBAuth call pattern:
- Sets
intAppID = 6and callsSetEntraAPPIdValues, passing the Bookings business SMTP
address asURLParameter1. This constructs the full endpoint URL. - Calls
AcquireBearerTokento obtain a delegated OAuth2 token. The authenticated user must
have access to the specified Bookings business. - Appends a
$top=50page size and astartDateTimedate range filter to the URL, covering
today and the following day. The date range is constructed fromNow()at runtime. - Sends a GET request and parses the JSON response.
- For each appointment returned, checks that
customerNameis non-empty. Entries without a
customer name are silently skipped — this filters out internal calendar blocks and
non-Bookings entries that the Graph API returns alongside genuine appointments. - Extracts
startDateTime,customerName, andserviceNamefrom each valid entry and
formats them as a display string. - Follows
@odata.nextLinkif present to retrieve additional pages. - Returns the formatted list and a count of genuine appointments found.
Date range note: The current implementation queries a 2-day window (today and tomorrow). Extending this range is straightforward — adjust the
DateAddcall in the URL construction. Be aware that wider ranges may return large numbers of entries that require more client-side processing, as server-side filtering is not available.
Behaviour Notes #
- The authenticated user must be a staff member or administrator of the specified Bookings business.
Access is delegated — the token represents the signed-in user, not an application identity. - The Bookings business is identified by its SMTP address (e.g.
mybusiness@contoso.com), which
is the email address associated with the Microsoft Bookings calendar, not the user’s address. - Dates returned by the API are in ISO 8601 format (
yyyy-mm-ddThh:mm:ss.0000000). The module
parses these usingMidandLeftstring functions rather thanCDate, to avoid locale-
dependent parsing failures. - If no appointments are found within the date range (after client-side filtering), the function
returnsTruewith an empty string and a count of zero. This is not an error condition.
Dependencies #
| Module | Purpose |
|---|---|
modVBAuthGlobalConstants.bas | Globals, SetEntraAPPIdValues, AcquireBearerToken |
JSONConverter.bas | Tim Hall VBA-JSON — JSON parsing |
Calling Example #
Dim strList As String
Dim lngCount As Long
If GetBookingAppointments(strList, lngCount, "mybusiness@contoso.com") Then
' strList contains formatted appointment lines (date | customer | service)
' lngCount is the number of genuine Bookings appointments found
Else
' strList contains the error message
End If
Code language: PHP (php)
VBAuth, developed and maintained by Andrew Richards (The IT Service Ltd) and Peter Bryant (Corylus Business Systems), © 2025–2026. All rights reserved. https://vbauth.com