README List Bookings

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.All is 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 NameRequired Value / ExampleNotes
AppID6Identifies this feature’s configuration record
ActionNameVBAuth – List BookingsDisplay 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
ScopeClaimsBookingsAppointment.ReadWrite.AllComma-separated Graph scopes
VerbGETHTTP method
URLPart1https://graph.microsoft.com/v1.0/solutions/bookingBusinesses/Base endpoint — Bookings business SMTP address appended at runtime
URLParameter1Bookings calendar SMTP addresse.g. mybusiness@contoso.com — substituted at runtime
URLPart2/appointmentsAppended after URLParameter1
URLParameter2NO VALUE REQUIREDNot used
URLPart3NO VALUE REQUIREDNot used
WaitForLogin60Seconds — 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):

  1. Go to Microsoft Entra ID → App registrations → New registration
  2. Name: e.g. VBAuth - Bookings
  3. Supported account types: Single tenant
  4. Redirect URI: Platform = Public client/native, URI = http://localhost
  5. Click Register
  6. Copy the Application (Client) ID and Directory (Tenant) ID from the Overview blade
  7. Go to API permissions → Add a permission → Microsoft Graph → Delegated permissions
  8. Add: BookingsAppointment.ReadWrite.All
  9. Click Grant admin consent

How It Works #

GetBookingAppointments follows the standard VBAuth call pattern:

  1. Sets intAppID = 6 and calls SetEntraAPPIdValues, passing the Bookings business SMTP
    address as URLParameter1. This constructs the full endpoint URL.
  2. Calls AcquireBearerToken to obtain a delegated OAuth2 token. The authenticated user must
    have access to the specified Bookings business.
  3. Appends a $top=50 page size and a startDateTime date range filter to the URL, covering
    today and the following day. The date range is constructed from Now() at runtime.
  4. Sends a GET request and parses the JSON response.
  5. For each appointment returned, checks that customerName is 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.
  6. Extracts startDateTime, customerName, and serviceName from each valid entry and
    formats them as a display string.
  7. Follows @odata.nextLink if present to retrieve additional pages.
  8. 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 DateAdd call 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 using Mid and Left string functions rather than CDate, to avoid locale-
    dependent parsing failures.
  • If no appointments are found within the date range (after client-side filtering), the function
    returns True with an empty string and a count of zero. This is not an error condition.

Dependencies #

ModulePurpose
modVBAuthGlobalConstants.basGlobals, SetEntraAPPIdValues, AcquireBearerToken
JSONConverter.basTim 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

Updated on April 3, 2026