Unknown error when call https://graph.microsoft.com/v1.0/solutions/bookingBusinesses/MSBookingPlayground@pricefx.com/appointments

Hung Bui 20 Reputation points
2024-08-28T04:27:05.18+00:00

Hi Support team

I get access token by:

https://login.microsoftonline.com/7894512c-f554-4de4-bff2-dec418150d4c/oauth2/v2.0/token

Then call https://graph.microsoft.com/v1.0/solutions/bookingBusinesses/MSBookingPlayground@pricefx.com/appointments

The response is

{
    "error": {
        "code": "UnknownError",
        "message": "",
        "innerError": {
            "date": "2024-08-28T04:16:54",
            "request-id": "3ec31e83-eff5-4e5e-82ff-cc2348f11643",
            "client-request-id": "3ec31e83-eff5-4e5e-82ff-cc2348f11643"
        }
    }
}

My purpose for this ticket is:

  • I could list all booking by REST API
  • I could cancel a booking by REST API with booking Id

I create the question here by guideline from support-eu@mail.support.microsoft.com

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,824 questions
{count} votes

Accepted answer
  1. Yakun Huang-MSFT 4,160 Reputation points Microsoft Vendor
    2024-08-28T09:03:57.9266667+00:00

    Hi @Hung Bui

    According to your error message, the error is caused by the token. Please follow the process of auth code flow to obtain the token. When obtaining the token, the user needs to interactively log in and authorize, otherwise, error 401 will be reported.

    The permission you need to grant when getting the token is Bookings.Read.All, which needs to be listed in the scope parameter.

    In addition, the List appointments endpoint also supports the use of application permissions, and when you use application permissions, you need to obtain the token according to the client credentials flow.

    Finally, you can also refer to the following two examples of obtaining tokens:

    https://learn.microsoft.com/en-us/graph/auth-v2-user?tabs=http

    https://learn.microsoft.com/en-us/graph/auth-v2-service?tabs=http

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.


1 additional answer

Sort by: Most helpful
  1. Hitesh Pachipulusu - MSFT 1,180 Reputation points Microsoft Vendor
    2024-08-28T12:40:25.61+00:00

    Hello Hung Bui,

    Greetings from Microsoft Support!

    It looks like you’re encountering an “UnknownError” when trying to list all bookings using the Microsoft Graph API. Here are a few steps you can take to troubleshoot this issue:

    1. Check Permissions: Ensure that the access token you’re using has the necessary permissions to access the bookings. You might need permissions like Bookings.Read.All, BookingsAppointment.ReadWrite.All , Bookings.Manage.All and Bookings.ReadWrite.All.
    2. Validate Access Token: Use a tool like jwt.io to decode your access token and verify that it contains the correct scopes.
    3. API Endpoint: Double-check the API endpoint URL to ensure it’s correct and that the booking business ID (MSBookingPlayground@pricefx.com) is accurate. List all Booking Appointments: To list all the Booking Appointments, you can use below Graph API endpoint. Please check documentation.
    GET https://graph.microsoft.com/v1.0/solutions/bookingBusinesses/{id}/appointments
    

    User's image

    Cancel a Booking Appointment: To cancel a Booking Appointment, you can use below Graph API endpoint. Please check documentation.

    POST https://graph.microsoft.com/v1.0/solutions/bookingBusinesses/{id}/appointments/{id}/cancel
    Content-type: application/json
    {
      "cancellationMessage": "Your appointment has been successfully cancelled. Please call us again."
    }
    

    User's image

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.