r/GraphAPI • • Jun 06 '24

I can't seem to get permissions to scope when connecting to graph through an app

3 Upvotes

I registered a new app, applied the "User.ReadWrite.All" permission as an application permission, created a self-signed certificate, uploaded it, used the thumbprint to connect and it all LOOKS fine. Even running

(Get-MgContext).Scopes

yields the "User.ReadWrite.All" as if I have the permissions with this session. But when I run any Update-MgUser command I get access denied. Can someone smarter than me help?

Edit: Ok, I realized I'm trying to modify the phone attributes of users and getting denied, but I can apply other attributes like job title. Anyone know what I need to do to allow an application to modify non-admin mobile phone attributes?


r/GraphAPI • • Sep 02 '24

[ Help Needed ] Need a Graph API to update device ownership of a device using .NET

1 Upvotes

Hi everyone,

I am looking to update device ownership of a device in AAD using Microsoft Graph API

This closest I have come to is https://learn.microsoft.com/en-us/graph/api/device-post-registeredowners?view=graph-rest-1.0&tabs=csharp but this needs delegated permission.

I would like to do it directly using Application permission type because I have to do the ownership change using a background process without any user involvement.

Note: My devices are not managed by Intune


r/GraphAPI • • Jul 25 '24

Change Notifications API - What constitutes a notification?

1 Upvotes

I'm working with the Change Notifications API and it's not clear to me what changes will trigger a notification.

Specifically, for the User resource, I assume it notifies when the default User Properties change, but does it also include:

In my use case, for each user I have to fetch a bunch of relationships, it'd be great if I could rely on the notifications API to trigger a fetch of these, as needed, rather than polling 24/7.

I know I'm being optimistic here, just wondering if anyone has tested this.


r/GraphAPI • • Aug 19 '24

help using graph api

1 Upvotes

I have a react addin which uses SSO, and I want to use the access token returned by this method in the Office js api in my .net rest api to get data on behalf of the user, however, it seems I need to use the on behalf of flow to be able to do so and that requires a client secret that expires, is that the only way? can I make graph api calls on behalf of the user without client secret?


r/GraphAPI • • Jan 23 '24

Intune get installed apps on a device PowerShell Graph API

2 Upvotes

$TenantID="xxx"
$ClientID="yyy"
$Secret= "zzz"
$uri="https://login.microsoftonline.com/$TenantID/oauth2/token"
$body= @{
grant_type="client_credentials"
client_id = $ClientID
client_secret=$secret
resource="https://graph.microsoft.com/"
}
$resp=Invoke-RestMethod -Method Post -Uri $uri -Body $body -ContentType "application/x-www-form-urlencoded"
$token=$resp.access_token
Write-Host $resp.access_token

$targetParameter = (Get-Command Connect-MgGraph).Parameters['AccessToken']
if ($targetParameter.ParameterType -eq [securestring]){
Connect-MgGraph -AccessToken ($token |ConvertTo-SecureString -AsPlainText -Force)
}
else {
Connect-MgGraph -AccessToken $token
}
Connect-MgGraph -Scopes "User.Read.all", "  DeviceManagementManagedDevices.ReadWrite.All"

Get-MgDevice | Select-Object * | where {$_.DisplayName -eq "NYC-kPGJXIgO8N2"}

# I am able to get the device but how do i get installed apps

Please help


r/GraphAPI • • Aug 06 '24

Access and rights requirements for pulling a customised Compliance report for Windows features / quality patch installations.

3 Upvotes

My team needs to build some customized compliance reports (like KB number / version / date) for Patches and windows quality/ features updates for Windows devices..

Now as I understand, we can do it only via Graph API. But, my client doesn’t want to provide us standard access.. they asked me to get specific information/ attributes which are just sufficient to pull out such report…

Any guidance which all would be our must to have access to generate such reports from Graph API?

Thanks!


r/GraphAPI • • Jan 31 '25

Post to Additional Details field in for audit log?

1 Upvotes

We have an application that modifies user properties through Graph. Those changes are (obviously) recorded in the Audit Log. What would be GREAT is if we could include a comment that would also appear in the audit log.

Is there anywhere in the API that exposes the "Additional Details" field, so that a comment can be added about who initiated the change or why? The Initiated By (Actor) field is just the name of the application. While the application logs its activity separately, exposing that data in the Audit log would be even better.

Is anyone aware how to do this? Or is that a Microsoft Support question?


r/GraphAPI • • Oct 06 '23

Microsoft Graph Calendar API all-day events timezone issue

1 Upvotes

I'm getting this issue while fetching calendar events that all-day events are not obeying the prefer outlook.timezone. They are being returned as dates in the calendar user's timezone.

I need a solution to this as I save these events in my application and need to know the time zone before saving them.

I reported the question on Microsoft QA with additional details please have a look at that as well:

https://learn.microsoft.com/en-us/answers/questions/1382503/all-day-events-are-not-obeying-prefer-outlook-time


r/GraphAPI • • Oct 10 '23

Question, easy guide to change the "employeeLeaveDateTime" attribute on a user trough Graph?

1 Upvotes

How do I accomplish this? I'm not experienced in Graph so a simple guide would be really helpfull!


r/GraphAPI • • May 12 '24

Microsoft Graph question - Single day all-day event spans two days in outlook calendar app?

1 Upvotes

When i add the all day event via Microsoft graph api it extends to the next date.

But after i click on the event it displays the event as all-day event


r/GraphAPI • • Mar 20 '24

Microsoft Plans to Retire Application Impersonation Role in Exchange Online!

Thumbnail
self.admindroid
1 Upvotes

r/GraphAPI • • May 24 '24

Entra ID Connect Health Alerts

1 Upvotes

Anyone know of a way to pull Entra ID connect sync health alerts? The closest query I can see is Get /organization. This includes a last sync time.


r/GraphAPI • • Jan 21 '24

Best Practices for Integrating Microsoft Calendar API into Salon Chatbot – Seeking Advice!

1 Upvotes

Hello!

I'm currently developing a chatbot aimed at streamlining salon appointment bookings, and I'm diving into the world of Microsoft Calendar API for integration. The objective is to let the chatbot schedule appointments on behalf of both the salon and its employees.

I'm facing two major challenges and could use your expertise:

  1. Managing Salon Availability:

  • How do you recommend letting salons manage their availability inside microsoft calendar so that the getSchedule API can see when the salon is available.

  • (a little background) If I would use the working hours feature, then i won't be able to have the staff of the salon have a shared account, since the working hours only count for the entire account (I think).

  • Another option is to let the salon staff create recurring events with "status"/"showAs": "free" (when creating an event inside outlook calendar, in the top part you can change busy to free when creating an event). This option truly is a bad idea organization wise, but gets the job done so thats why i mention it.

  1. Structuring Multiple Calendars:

  • What's the best way to structure different calendars for salon employees? How could permissions for accessing each other's calendars be managed? Can I share agendas through API's or should I let staff have a shared account?

I'm still learning the ropes of Microsoft APIs and feeling a bit stuck in the calendar/booking part of my project. If you think Microsoft Calendar might not be the best fit, I'm open to alternative suggestions that align with my goals.

Your insights, recommendations, and tips would be immensely valuable in steering this project in the right direction. Thanks a bunch for your help!


r/GraphAPI • • Oct 08 '24

Empty response to Graph query on mails in a folder which actually has mail items visible in mailbox!!

1 Upvotes

r/GraphAPI • • Aug 06 '24

The Importance of API Development in Modern Software Engineering

Thumbnail
quickwayinfosystems.com
2 Upvotes

r/GraphAPI • • Sep 27 '24

Getting Settings for "Custom" CalendarPermissions

1 Upvotes

https://learn.microsoft.com/en-us/graph/api/resources/calendarpermission?view=graph-rest-1.0

When doing a GET for CalendarPermissions (https://graph.microsoft.com/v1.0/users/<ID>/calendar/calendarPermissions) one of the possible values for the "Role" property is "custom," representing permissions settings that don't fall into one of the pre-defined configurations. Unfortunately the response from Graph doesn't provide the capabilities "custom" represents, nor do I see a way within Graph to gather them:

id: <ID value>

isRemovable: True

isInsideOrganization: True

role: custom

allowedRoles: {freeBusyRead, limitedRead, read, write...}

emailAddress: @{name=<displayname>; address=<email address>}

I know I can get more information with a PowerShell Get-MailboxFolderPermissions or via EWS but neither is a good option for the application I'm working on. Does anyone happen to know a way I can figure out what actual capabilities are behind a "custom" role on a calendar permissions entry?

I figure I ought to be able to find that information within Graph via extended MAPI properties but I'd have to hunt down exactly which property to examine.

Thanks in advance for the help!


r/GraphAPI • • Feb 03 '25

How do you re-assign a primary user to an Intune device with the Graph API

2 Upvotes

We're struggling with finding a way to use the Graph API to re-assign a primary user to a device in Intune. We've built a custom loaning center application where we'd need to replace the primary user whenever a device is checked out so that the customer can access the Company Portal. We've tried a variety of API actions, some of which existed in the beta version of the API, which no longer exist or are no longer options. We've tried

https://graph.microsoft.com/v1.0/deviceManagement/windowsAutopilotDeviceIdentities/{windowsAutopilotDeviceIdentityId}/assignUserToDevice

Patching this with the body of the request being the userPrincipalName:

https://graph.microsoft.com/v1.0/deviceManagement/managedDevices/{managedDeviceId}

The last one looks like it should work, but we get an error when running it. Does anyone have thoughts on how to get this to work, assuming it can or we should be able to do it?


r/GraphAPI • • Jan 16 '24

Fetching list of ‘Search terms’ on SharePoint’s search box using graph api.

1 Upvotes

I am looking to create a power bi report to analyze search terms users are putting into the search box in SharePoint. Can this be accomplished using graph api ?


r/GraphAPI • • Sep 13 '24

Trying to create a MS list with a "Person or Group" field

2 Upvotes

I have been having the worst luck when trying to create a function that will create a ms list with the graph. I am able to create generic fields just fine with simple text. However, I have looked everywhere for documentation on how to fill out a "Person or Group" type field in a list. I am trying to have more control over what gets created. Previously I was using Power Automate and that was easy enough to create that field. I just needed to supply the user's email. However, now that I am using Python I am not sure what all I need to provide. I keep getting back "error":{"code":"invalidRequest","message":"Invalid request","innerError"

What I first found was that you needed to provide a Sharepoint lookup ID. Which I tried with no luck. Then I provided a dictionary with a number of values such as email, principal name, and display name.

Any help with this would be much appreciated.


r/GraphAPI • • Oct 16 '24

Trying to copy Teams Channel POST to another Channel and cannot copy hostedContent

1 Upvotes

I have a Teams Channel where I need to copy the POSTS to another Channel. I am using MS Graph API. Trying to copy the HostedContent (3 embedded img tags) throws an error. Combined, they exceed the 4194304 stream size limit.

Creating the POST without the hosted content, then going back and Updating that POST 3 times with each content doesn't work.

How do I get the HostedContents copied over? (would be nice if I could also make the new post as the original user)

    $url = "https://graph.microsoft.com/v1.0"
    $val = '$value'
    $quot = '"'

    $msgbody = $msg.body.content

    $uri = "$url/teams/$srcteamid/channels/$srcchannelid/messages/$($msg.id)/hostedContents"
    $hostedContents = (Invoke-MgGraphRequest -Uri $uri -Method GET).value
    if ($hostedContents -ne $null) {
        ForEach ($hc in $hostedContents) {
            $uri = "$url/teams/$srcteamid/channels/$srcchannelid/messages/$($msg.id)/hostedContents/$($hc.id)/$val"
            Invoke-MgGraphRequest -Uri $uri -Method GET -OutputFilePath "$($hc.id).png"
        }

        $HostedContentArray = @()
        $img = 0
        $totsize = 0
        $idx = 1
        While ($idx -lt $hostedContents.Length) {
            $hc = $hostedContents[$idx]
            $contentid = $hc.id
            $imgsize = (Get-Item "$contentid.png").Length
            if ($totsize + $imgsize -le 4194304) {
                $totsize += $imgsize
                $img++
                $txt = "$url/teams/$srcteamid/channels/$srcchannelid/messages/$($msg.id)/hostedContents/$contentid/$val"
                $txt = $txt.replace(".", "\.").replace("/", "\/").replace("$", "\$")
                $patt = "src=$quot$txt$quot"
                $msgbody = $msgbody -replace $patt, "src=$quot../hostedContents/$img/$val$quot"

                $obj = @{
                    "@microsoft.graph.temporaryId" = "$img"
                    contentBytes = [System.Convert]::ToBase64String([IO.File]::ReadAllBytes("$contentid.png"))
                    contentType = "image/png"
                }
                $HostedContentArray += $obj
            }
            $idx++
        }
    }

    $msg_datetime = [TimeZoneInfo]::ConvertTimeBySystemTimeZoneId($msg.createdDateTime, 'Eastern Standard Time')
    $msg_subject = "ON $msg_datetime, $($msg.from.user.displayName) posted: $($msg.subject)"
    $uri = "$url/teams/$destteamid/channels/$destchannelid/messages"
    $params = @{
        subject = $msg_subject
        body = @{
            contentType = $msg.body.contentType
            content = $msgbody
        }
        importance = $msg.importance
        mentions = $msg.mentions
        from = $msg.from
    }
    if ($HostedContentArray.length -gt 0) {
        $params.hostedContents = $HostedContentArray
    }

    $dest_msg = Invoke-MgGraphRequest -Uri $uri -Method POST -Body $params

            $msgbody = $dest_msg.body.content
            $img = 0
            $idx = 0
            $HostedContentArray = @()
            $hc = $hostedContents[$idx]
            $contentid = $hc.id
                $img++
                $txt = "$url/teams/$srcteamid/channels/$srcchannelid/messages/$($msg.id)/hostedContents/$contentid/$val"
                $txt = $txt.replace(".", "\.").replace("/", "\/").replace("$", "\$")
                $patt = "src=$quot$txt$quot"
                $msgbody = $msgbody -replace $patt, "src=$quot../hostedContents/$img/$val$quot"

                $obj = @{
                    "@microsoft.graph.temporaryId" = "$img"
                    contentBytes = [System.Convert]::ToBase64String([IO.File]::ReadAllBytes("$contentid.png"))
                    contentType = "image/png"
                }
                $HostedContentArray += $obj

            $params = @{
                subject = $msg_subject
                body = @{
                    contentType = $msg.body.contentType
                    content = $msgbody
                }
                hostedContents = $HostedContentArray
            }
            $uri = "$url/teams/$destteamid/channels/$destchannelid/messages/$($dest_msg.id)"
            Invoke-MgGraphRequest -Uri $uri -Method PATCH -Body $params

r/GraphAPI • • Aug 15 '23

Obtaining the access token from Connect-MgGraph

4 Upvotes

Once connected with Connect-MgGraph, how can I obtain/output the access token?


r/GraphAPI • • Dec 04 '24

Filter / Sort OneDrive/SharePoint Files

1 Upvotes

Hi everyone,

I’m integrating my app with SharePoint and need to retrieve all files visible to a user, including those in nested directories. For this, I’ve been using the next API with empty search params

/me/drive/root/search

Now, we want to support filtering and sorting with more complex conditions. For example, I need to retrieve a list of files that:

  • Were created by the current user,

  • Were modified within the last week,

  • Contain a specific text in the file name,

  • Have a specific file format (or one of several formats),

  • And return the results sorted in a particular order.

I think I need to use a different API for this functionality. Does anyone have experience with such use cases? Which API would be the most appropriate for filtering and sorting files in this way, and how would you structure the request?

Thanks in advance!

Maybe this API will cover my case?

v1.0/search/query

{
    "requests": [
        {
            "entityTypes": [
                "driveItem"
            ],
            "query": {
                "queryString": "(filetype:docx OR filetype:doc) AND ..."
            }
        }
    ]
}

r/GraphAPI • • Dec 27 '24

How can I retrieve MS 365 copilot data of employees using GraphAPI or any other way?

1 Upvotes

I am trying to find a way of accessing search history, prompts, messages, etc of employees using MS copilot withing an organisation. I came across so many articles and docs and there are different ways and lot information to understand and digest. Can anyone provide me any straight forward way of doing this?

I am expecting some API ways just like GraphAPI.


r/GraphAPI • • Nov 29 '23

Cannot find "Meeting_id" to be used in "Get All Recordings" API endpoint call for microsoft teams.

2 Upvotes

I am trying to run the "Get All Recordings" endpoint call on Postman. https://graph.microsoft.com/v1.0/me/onlineMeetings/{meeting_id}/recordings The above call needs a Meeting_id which I cannot find from any other endpoint call or from Microsoft Teams UI. I tried to create a meeting, get the response of it and using meeting_id from response but it gives me following error: "message": "No iCalUid found for the meeting. This API is supported only for calendar backed OnlineMeeting."

One of the meeting_id is what you get from meeting detail page on MS Teams but that is not acceptable.

Is there a way we can get the meeting_id to run Get all Recordings call?