I'm getting Bad Request 400 for a certain MS Graph requests

Emil Marashliev 0 Reputation points
2024-09-26T11:01:24.43+00:00

Hello there,

I'm trying to create an iOS app that consume graph.microsoft.com. But I have issues with some endpoints, I'm getting Bad Request 400 , for example when I try to create virtualEvent Townhall.

Here is the request:

POST https://graph.microsoft.com/v1.0/solutions/virtualEvents/townhalls HTTP/2
host: graph.microsoft.com
accept: */*
content-type: application/json
accept-encoding: gzip, deflate, br
authorization: Bearer eyJ0eXAiOiJKV1QiLCJub25jZSI6IkxkNUk5MlA1d243bm1xVkdTcE55b19XS2E5MW9DVHI2SFE2aXh3a09ra3MiLCJhbGciOiJSUzI1NiIsIng1dCI6Ikg5bmo1QU9Tc3dNcGhnMVNGeDdqYVYtbEI5dyIsImtpZCI6Ikg5bmo1QU9Tc3dNcGhnMVNGeDdqYVYtbEI5dyJ9.eyJhdWQiOiIwMDAwMDAwMy0wMDAwLTAwMDAtYzAwMC0wMDAwMDAwMDAwMDAiLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC8xNWQzMTYwMS1hZDE2LTRhYTAtODdmNC1iZWQ2ZDNmMGE0YWEvIiwiaWF0IjoxNzI3MjY5OTUzLCJuYmYiOjE3MjcyNjk5NTMsImV4cCI6MTcyNzM1NjY1MywiYWNjdCI6MCwiYWNyIjoiMSIsImFpbyI6IkFUUUF5LzhYQUFBQVc5cytKK1B1ZGlBUlIyNjFMeDVTZEwveXRQcWF0bUhWSmZhSmgxTzRJdjA1SGdseVRYa3BXZHBsWDlzN3QzQUIiLCJhbXIiOlsicHdkIl0sImFwcF9kaXNwbGF5bmFtZSI6IkdyYXBoIEV4cGxvcmVyIiwiYXBwaWQiOiJkZThiYzhiNS1kOWY5LTQ4YjEtYThhZC1iNzQ4ZGE3MjUwNjQiLCJhcHBpZGFjciI6IjAiLCJmYW1pbHlfbmFtZSI6IlNlY29uZE5hbWVUb29MYXJnZSIsImdpdmVuX25hbWUiOiJ2bXdVc2VyMiIsImlkdHlwIjoidX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ZhJKLQ6nTN1iGSFMrtArgVnbeWqjsWgVUJncjM1J8YZ4AmAUQFofp_DW8AkxtJCo9v3uGXs5wjJYpcNBhEJKajbsqmC4qdBG_syNVOTBPg6eJAX_e1XopPGgN9DfJ7ATe3zMc2xw3KkiG2WgK3PEkDmKi9k1FMpwe5jd1cSD7umODbc_vHMY2uAte58zIeYS72ds-jQw
user-agent: TestProject/1 CFNetwork/1568.100.1 Darwin/23.6.0
accept-language: en-GB,en;q=0.9
content-length: 613

{     
    "displayName": "The Impact of Tech on Our Lives",
    "description": {
      "contentType": "text",
      "content": "Discusses how technology has changed the way we communicate."
    },
    "startDateTime": {
      "dateTime": "2025-03-30T10:00:00", 
      "timeZone": "Pacific Standard Time" 
    },
    "endDateTime": {
      "dateTime": "2025-03-30T17:00:00", 
      "timeZone": "Pacific Standard Time" 
    },
    "audience": "organization",
    "coOrganizers": [],
    "settings": {
      "isAttendeeEmailNotificationEnabled": false
    }
}

And the Response:

HTTP/2 400
content-type: application/json
content-encoding: gzip
vary: Accept-Encoding
strict-transport-security: max-age=31536000
request-id: bc61c7a9-0e1d-463f-9080-b9d5fcf42e3d
client-request-id: bc61c7a9-0e1d-463f-9080-b9d5fcf42e3d
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"Germany West Central","Slice":"E","Ring":"4","ScaleUnit":"003","RoleInstance":"FR1PEPF00001392"}}
scenario-id: 8703daae-1a34-49f1-bbe0-ee09e78eed87
date: Thu, 26 Sep 2024 08:39:53 GMT

{
    "error": {
        "code": "BadRequest",
        "message": "Bad Request",
        "innerError": {
            "date": "2024-09-26T08:39:53",
            "request-id": "bc61c7a9-0e1d-463f-9080-b9d5fcf42e3d",
            "client-request-id": "bc61c7a9-0e1d-463f-9080-b9d5fcf42e3d"
        }
    }
}

Do you an idea what might cause this issue?

Thanks in advance!

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,041 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Hitesh Pachipulusu - MSFT 2,145 Reputation points Microsoft Vendor
    2024-09-26T11:59:21.9866667+00:00

    Hello Emil Marashliev,

    Thank you for reaching out to Microsoft Support!

    It looks like you’re encountering a “Bad Request” (400) error when trying to create a virtualEvent Townhall using the Microsoft Graph API. Here are a few things you might want to check:

    1. Permissions: Verify that your app has the necessary permissions. For creating a virtualEvent Townhall, you need the VirtualEvent.ReadWrite permission.
    2. Request Body: Double-check the JSON structure of your request body. Ensure all required fields are included and correctly formatted. For example, the startDateTime and endDateTime should be in the correct dateTimeTimeZone format.
    3. Token: Make sure your Bearer token is valid and has not expired. Also, ensure it has the necessary scopes for the operation you’re trying to perform.
    4. Headers: Ensure all required headers are included in your request. The Content-Type should be application/json, and the Authorization header should contain a valid Bearer token.

    If everything seems correct and you’re still facing issues, you might want to try testing the request using a tool like Postman to isolate whether the issue is with your code or the API itself.

    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.


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.