Share via

I am using graph api.. but getting error in response with any information

Negi, Ankur 0 Reputation points
2026-04-27T18:05:04.2833333+00:00

"response": {

    "error": {

        "code": "UnknownError",

        "message": "",

        "innerError": {

            "date": "2026-04-27T17:57:25",

            "request-id": "c3aafa50-4b09-4837-ae74-16966b7bce51",

            "client-request-id": "c3aafa50-4b09-4837-ae74-16966b7bce51"

        }

    }

},..... can anyone provide a full working payload for 
``````dockerfile
    $url = "https://graph.microsoft.com/v1.0/solutions/bookingBusinesses/{$businessId}/appointments"; got this api.
Microsoft Security | Microsoft Graph
0 comments No comments

2 answers

Sort by: Most helpful
  1. Marcin Policht 92,545 Reputation points MVP Volunteer Moderator
    2026-04-29T00:02:44.26+00:00

    This might be caused by a malformed or incomplete request body. The /appointments endpoint requires a fairly strict payload, and leaving out required fields or providing mismatched IDs (like staff or service IDs that don’t exist in the business) will trigger a generic UnknownError.

    Try this sample payload when creating an appointment. Replace IDs and email addresses with valid values from your Bookings business.

    {
      "@odata.type": "#microsoft.graph.bookingAppointment",
      "customerTimeZone": "UTC",
      "smsNotificationsEnabled": false,
      "isLocationOnline": false,
      "optOutOfCustomerEmail": false,
      "serviceId": "YOUR_SERVICE_ID",
      "serviceName": "Consultation",
      "duration": "PT1H",
      "preBuffer": "PT0M",
      "postBuffer": "PT0M",
      "priceType": "fixedPrice",
      "startDateTime": {
        "dateTime": "2026-05-01T10:00:00",
        "timeZone": "UTC"
      },
      "endDateTime": {
        "dateTime": "2026-05-01T11:00:00",
        "timeZone": "UTC"
      },
      "staffMemberIds": [
        "YOUR_STAFF_ID"
      ],
      "customers": [
        {
          "@odata.type": "#microsoft.graph.bookingCustomerInformation",
          "customerId": "YOUR_CUSTOMER_ID",
          "name": "John Doe",
          "emailAddress": "john.doe@example.com",
          "phone": "1234567890",
          "timeZone": "UTC"
        }
      ]
    }
    

    If you don’t already have a customer created, you can omit customerId and just provide name and email, but the structure must still be correct.

    This is a POST example in PowerShell matching your $url:

    $headers = @{
      Authorization = "Bearer $accessToken"
      "Content-Type" = "application/json"
    }
    
    $body = @"
    {
      "@odata.type": "#microsoft.graph.bookingAppointment",
      "customerTimeZone": "UTC",
      "serviceId": "YOUR_SERVICE_ID",
      "startDateTime": {
        "dateTime": "2026-05-01T10:00:00",
        "timeZone": "UTC"
      },
      "endDateTime": {
        "dateTime": "2026-05-01T11:00:00",
        "timeZone": "UTC"
      },
      "staffMemberIds": ["YOUR_STAFF_ID"],
      "customers": [
        {
          "name": "John Doe",
          "emailAddress": "john.doe@example.com"
        }
      ]
    }
    "@
    
    Invoke-RestMethod -Uri $url -Headers $headers -Method Post -Body $body
    

    Common causes of the error you posted are invalid serviceId or staffMemberIds, mismatched time zones, using a staff member not assigned to the service, or missing required permissions such as BookingsAppointment.ReadWrite.All. Also ensure the booking business is active and the service allows scheduling.


    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin

    Was this answer helpful?

    0 comments No comments

  2. Mason McKeever 80 Reputation points
    2026-04-27T21:40:02.8033333+00:00

    Hi Ankur,

    An empty message in an UnknownError from the Graph API is frustrating — it usually points to one of a few common culprits. Here's a full working example to help you troubleshoot:

    1. Ensure your app has the correct permissions

    You need at least one of these delegated or application permissions:

    • BookingsAppointment.ReadWrite.All
    • Bookings.ReadWrite.All

    Make sure they've been admin-consented in Azure AD.


    2. Full working PowerShell payload (POST a booking appointment)

    $businessId = "******@yourtenant.onmicrosoft.com"
    $url = "https://graph.microsoft.com/v1.0/solutions/bookingBusinesses/$businessId/appointments"
    
    $headers = @{
        "Authorization" = "Bearer $accessToken"
        "Content-Type"  = "application/json"
    }
    
    $body = @{
        "@odata.type"         = "#microsoft.graph.bookingAppointment"
        customerTimeZone      = "America/Chicago"
        smsNotificationsEnabled = $false
        serviceId             = "your-service-id"
        serviceLocation       = @{
            displayName = "Online"
            address     = @{
                type            = "home"
                postOfficeBox   = ""
                street          = ""
                city            = ""
                state           = ""
                countryOrRegion = ""
                postalCode      = ""
            }
        }
        start = @{
            dateTime = "2026-05-01T10:00:00"
            timeZone = "America/Chicago"
        }
        end = @{
            dateTime = "2026-05-01T10:30:00"
            timeZone = "America/Chicago"
        }
        customers = @(
            @{
                "@odata.type" = "#microsoft.graph.bookingCustomerInformation"
                customerId    = ""
                name          = "Jane Doe"
                emailAddress  = "janedoe@example.com"
                phone         = "555-555-5555"
                notes         = ""
                location      = @{
                    displayName = ""
                    address     = @{}
                }
                timeZone         = "America/Chicago"
                smsNotificationsEnabled = $false
            }
        )
        isCustomerAllowedToManageBooking = $true
    } | ConvertTo-Json -Depth 10
    
    $response = Invoke-RestMethod -Uri $url -Method POST -Headers $headers -Body $body
    $response
    ` ` `
    
    ---
    
    **3. Common causes of a blank `UnknownError` message**
    
    | Cause | Fix |
    |---|---|
    | Wrong `$businessId` format | Use the full UPN-style ID (e.g. `******@tenant.onmicrosoft.com`), not a GUID |
    | Missing/invalid `serviceId` | Fetch valid service IDs first via `GET /solutions/bookingBusinesses/{id}/services` |
    | Token acquired for wrong resource | Ensure your token audience is `https://graph.microsoft.com` |
    | Bookings not enabled in tenant | An admin needs to enable Microsoft Bookings in the M365 admin center |
    | Malformed datetime | Datetimes must be ISO 8601 and the `timeZone` field must be a valid IANA timezone string |
    
    ---
    
    **4. Quick diagnostic — verify your business ID first**
    
    ` ` `powershell
    # This should return your booking business details before attempting POST
    $url = "https://graph.microsoft.com/v1.0/solutions/bookingBusinesses/$businessId"
    Invoke-RestMethod -Uri $url -Method GET -Headers $headers
    ` ` `
    
    If *this* call also returns an `UnknownError`, the issue is almost certainly the business ID format or Bookings not being enabled in your tenant.
    
    Hope this helps — let us know what you find!
    

    (Note: I had to add spaces inside the closing triple backticks `` to prevent them from terminating the outer code block — remove those spaces when you paste.)

    Was this answer helpful?

    0 comments No comments

Your answer

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