Can /me and /usersco-exist?

Mansi Gusain 315 Reputation points
2025-03-19T13:30:13.3466667+00:00

Hi this is my schema for the agent I built to get me my mails, send mails and create events.

openapi: 3.1.0

info:

title: Microsoft Graph API Integration

version: 1.0.0

servers:

components:

securitySchemes:

OAuth2:

  type: oauth2

  flows:

    clientCredentials:

      tokenUrl: https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token

      scopes:

        https://graph.microsoft.com/User.ReadBasic.All: Access other users profile

        https://graph.microsoft.com/User.Read: Access current user profile

        https://graph.microsoft.com/Mail.ReadBasic: Read user mail

        https://graph.microsoft.com/Mail.Send: Send mail

        https://graph.microsoft.com/Calendars.ReadWrite: Read and write user calendars

schemas:

UserProfile:

  type: object

  properties:

    id:

      type: string

    displayName:

      type: string

    mail:

      type: string

UserMessage:

  type: object

  properties:

    id:

      type: string

    subject:

      type: string

    bodyPreview:

      type: string

CalendarEvent:

  type: object

  properties:

    id:

      type: string

    subject:

      type: string

    start:

      type: object

      properties:

        dateTime:

          type: string

        timeZone:

          type: string

    end:

      type: object

      properties:

        dateTime:

          type: string

        timeZone:

          type: string

NewEvent:

  type: object

  properties:

    subject:

      type: string

    start:

      type: object

      properties:

        dateTime:

          type: string

        timeZone:

          type: string

    end:

      type: object

      properties:

        dateTime:

          type: string

        timeZone:

          type: string

    attendees:

      type: array

      items:

        type: object

        properties:

          emailAddress:

            type: object

            properties:

              address:

                type: string

              name:

                type: string

SendMailRequest:

  type: object

  properties:

    message:

      type: object

      properties:

        subject:

          type: string

        body:

          type: object

          properties:

            contentType:

              type: string

            content:

              type: string

        toRecipients:

          type: array

          items:

            type: object

            properties:

              emailAddress:

                type: object

                properties:

                  address:

                    type: string

security:

  • OAuth2: []

paths:

/me:

get:

  operationId: getMyProfile

  summary: Get the authenticated user's profile

  security:

    - OAuth2: []

  parameters:

    - name: $select

      in: query

      required: true

      schema:

        type: string

        description: OData query option to select properties

        example: mail,displayName,givenName

  responses:

    '200':

      description: A user profile

      content:

        application/json:

          schema:

            $ref: '#/components/schemas/UserProfile'

/me/messages:

get:

  operationId: getUserMessages

  summary: Get the authenticated user's messages

  security:

    - OAuth2: []

  parameters:

    - name: $top

      in: query

      required: false

      schema:

        type: integer

        default: 10

        description: Number of messages to return

    - name: $filter

      in: query

      required: false

      schema:

        type: string

        description: OData filter query to narrow results

    - name: $orderby

      in: query

      required: false

      schema:

        type: string

        description: OData order by query to sort results

  responses:

    '200':

      description: A list of user messages

      content:

        application/json:

          schema:

            type: array

            items:

              $ref: '#/components/schemas/UserMessage'

/me/sendMail:

post:

  operationId: sendUserMail

  summary: Send an email as the authenticated user

  security:

    - OAuth2: []

  requestBody:

    required: true

    content:

      application/json:

        schema:

          $ref: '#/components/schemas/SendMailRequest'

  responses:

    '202':

      description: Accepted

/me/events:

get:

  operationId: getUserCalendarEvents

  summary: Get the authenticated user's calendar events

  security:

    - OAuth2: []

  responses:

    '200':

      description: A list of calendar events

      content:

        application/json:

          schema:

            type: array

            items:

              $ref: '#/components/schemas/CalendarEvent'

post:

  operationId: createUserCalendarEvent

  summary: Create a new calendar event for the authenticated user

  security:

    - OAuth2: []

  requestBody:

    required: true

    content:

      application/json:

        schema:

          $ref: '#/components/schemas/NewEvent'

  responses:

    '201':

      description: Created

      content:

        application/json:

          schema:

            $ref: '#/components/schemas/CalendarEvent'

/me/outlook/supportedTimeZones:

get:

  operationId: getSupportedTimeZones

  summary: Get supported time zones for the authenticated user

  security:

    - OAuth2: []

  responses:

    '200':

      description: A list of supported time zones

      content:

        application/json:

          schema:

            type: array

            items:

              type: object

              properties:

                alias:

                  type: string

                displayName:

                  type: string

/users:

get:

  operationId: listUsers

  summary: List users

  security:

    - OAuth2: []

  parameters:

    - name: $filter

      in: query

      required: true

      schema:

        type: string

        description: OData filter query to narrow results

        example: startsWith(displayName,'[NAME]')

  responses:

    '200':

      description: A list of users

      content:

        application/json:

          schema:

            type: array

            items:

              $ref: '#/components/schemas/UserProfile'

and funny part is -

  1. If I fetch the user details for others and do not get it then I get mine if i ask to fetch
  2. If I get for other users then I do not get my email id if I query for it.

All the scopes are correct . As getting mail messages and sending events works. Just together these two apis fail 90% times.

How to resolve- User's image

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

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.