office 365
96 TopicsHow to get user photo in C# using Graph API?
I am building a bot which shows user the searched user photo and other information. Rest of the information is being fetched properly other than user's photo. I am trying to get user photo by using below URL. Graph explorer shows the user's photo using this URL. https://graph.microsoft.com/v1.0/users/{userid}/photo/$value I am using below code to get the image and assign it as URL to image card in my bot. private async Task<string> GetPhoto(HttpClient client, string id) { var resp = await client.GetAsync("https://graph.microsoft.com/v1.0/users/{id}/photo/$value"); var buffer = await resp.Content.ReadAsByteArrayAsync(); var byteArray = buffer.ToArray(); string base64String = Convert.ToBase64String(byteArray); Trace.WriteLine($"converted base 64 string! =>=>=>=> {base64String}"); return base64String; } is it the right way to fetch and show the user photo in C#?Solved65KViews0likes3CommentsGet-MgProfile : The term 'Get-MgProfile' is not recognized as the name of a cmdlet, function, script
Hi everyone, The cmdlet Get-MgProfile is no longer available after updating to v2.1.0 Even the link is no longer available: https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.people/get-mguserprofile What is the replacement Graph SDK cmdlet to get the existing Microsoft Graph PowerShell SDK connection profile name? Thanks in advance.16KViews1like5CommentsSharePoint Librarys: Graph API Get items
Hey, i wanna list all the items that are in a SharePoint library which is the root library of a Teamsite. In the Graph API documentation i have found the following to "List children of a driveItem". Which seems to be what i need. I'm using the Graph Explorer v1.0, i get an empty value. GET /drives/{drive-id}/items/{item-id}/children { "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('[Redacted]')/items('[Redacted]')/children", "value": [] } When getting the metadata of a drive (Get a DriveItem resource) I get the follwoing result. GET /drives/{drive-id}/items/{item-id}/ { "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('[Redacted]')/items/$entity", "createdDateTime": "2018-06-29T06:58:41Z", "id": "[Redacted]", "lastModifiedDateTime": "2021-02-01T11:44:01Z", "name": "root", "webUrl": "[Redacted]", "size": 14251577828, "parentReference": { "driveId": "[Redacted]", "driveType": "documentLibrary" }, "fileSystemInfo": { "createdDateTime": "2018-06-29T06:58:41Z", "lastModifiedDateTime": "2021-02-01T11:44:01Z" }, "folder": { "childCount": 17 }, "root": {} } So instead of the first result to be empty I'm expecting to get at least the 17 Children on the first level. I'd really appreciate any pointers as to what I'm doing wrong. Thanks EDIT: I created a new Teamsite in that Tenant and got the same results. /drives/[Drive-id-Redacted]/items/[item-id-redacted]/children { "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('Redacted')/items('Redacted')/children", "value": [] } I also did the same exact steps on another Tenant. Were i got the expected results. Everything on the first level of the document library was returned (empty folders, folders with content & files). GET drives/[drive-id-Redacted]/items/[item-id-Redacted]/children { "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('b%21AkpyLC5wkUKil3rDWQGKATkY1dsy_8VBn4bwuhbxbzG5iis7JuCiTYx7InpDx1E7')/items('0165NKSCF6Y2GOVW7725BZO354PWSELRRZ')/children", "value": [ { "createdDateTime": "2021-02-01T08:07:32Z", "eTag": "\"{Redacted},1\"", "id": "Redacted", "lastModifiedDateTime": "2021-02-01T08:07:32Z", "name": "_Test_Folder", "webUrl": "https://Redacted.sharepoint.com/sites/PowerAppsFunktionen/Freigegebene%20Dokumente/_Test_Folder", "cTag": "\"c:{Redacted},0\"", "size": 0, "createdBy": { "user": { "email": "mmuster@Redacted.com", "id": "Redacted", "displayName": "Max Muster" } }, "lastModifiedBy": { "user": { "email": "mmuster@Redacted.com", "id": "Redacted", "displayName": "Max Muster" } }, "parentReference": { "driveId": "Redacted", "driveType": "documentLibrary", "id": "Redacted", "path": "/drives/Redacted/root:" }, "fileSystemInfo": { "createdDateTime": "2021-02-01T08:07:32Z", "lastModifiedDateTime": "2021-02-01T08:07:32Z" }, "folder": { "childCount": 0 } }, { "createdDateTime": "2021-01-14T08:14:40Z", "eTag": "\"{Redacted},1\"", "id": "Redacted", "lastModifiedDateTime": "2021-01-14T08:14:40Z", "name": "Ordner", "webUrl": "https://Redacted.sharepoint.com/sites/PowerAppsFunktionen/Freigegebene%20Dokumente/Ordner", "cTag": "\"c:{Redacted},0\"", "size": 367581, "createdBy": { "user": { "email": "mmuster@Redacted.onmicrosoft.com", "id": "Redacted", "displayName": "Max Muster" } }, "lastModifiedBy": { "user": { "email": "mmuster@Redacted.onmicrosoft.com", "id": "Redacted", "displayName": "Max Muster" } }, "parentReference": { "driveId": "Redacted", "driveType": "documentLibrary", "id": "Redacted", "path": "/drives/Redacted/root:" }, "fileSystemInfo": { "createdDateTime": "2021-01-14T08:14:40Z", "lastModifiedDateTime": "2021-01-14T08:14:40Z" }, "folder": { "childCount": 22 } }, { "@microsoft.graph.downloadUrl": "https://Redacted.sharepoint.com/sites/PowerAppsFunktionen/_layouts/15/download.aspx?Redacted&ApiVersion=2.0", "createdDateTime": "2020-11-05T22:17:07Z", "eTag": "\"{Redacted},9\"", "id": "Redacted", "lastModifiedDateTime": "2020-11-06T10:33:09Z", "name": "Mappe.xlsx", "webUrl": "https://Redacted.sharepoint.com/sites/PowerAppsFunktionen/_layouts/15/Doc.aspx?sourcedoc=%7BRedacted%7D&file=Mappe.xlsx&action=default&mobileredirect=true", "cTag": "\"c:{Redacted},15\"", "size": 23064, "createdBy": { "user": { "email": "mmuster@Redacted.onmicrosoft.com", "id": "Redacted", "displayName": "Max Muster" } }, "lastModifiedBy": { "application": { "id": "Redacted", "displayName": "App Service" }, "user": { "email": "mmuster@Redacted.onmicrosoft.com", "id": "Redacted", "displayName": "Max Muster" } }, "parentReference": { "driveId": "Redacted", "driveType": "documentLibrary", "id": "Redacted", "path": "/drives/Redacted/root:" }, "file": { "mimeType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "hashes": { "quickXorHash": "Redacted" } }, "fileSystemInfo": { "createdDateTime": "2020-11-05T22:17:07Z", "lastModifiedDateTime": "2020-11-06T10:33:09Z" } }, [...] ] } Has anyone had a similar experience? In the first Library i thought it might have to do with the number of items in the Library (about 25.000). But the others are all under 50 items.9KViews0likes5CommentsApplication.ReadWrite.OwnedBy: List all applications owned by the calling application
Hi, I am trying to get only the applications that my app owns using Graph, and on the documentation it shows that I should be able to only list the applications where my app is owner. (This is to limit the content I have access to with my app) https://docs.microsoft.com/en-us/graph/permissions-reference Application Application.Read.All: List all applications (GET /beta/applications) Application.ReadWrite.All: Delete a service principal (DELETE /beta/servicePrincipals/{id}) Application.ReadWrite.OwnedBy: Create an application (POST /beta/applications) Application.ReadWrite.OwnedBy: List all applications owned by the calling application (GET /beta/servicePrincipals/{id}/ownedObjects) Application.ReadWrite.OwnedBy: Add another owner to an owned application (POST /applications/{id}/owners/$ref). NOTE: This may require additional permissions. However, if I create an app that has owner permissions on another app and I query against the Graph API "Applications" I am still able to list all applications in the tenant. I thought having me added as owner, on an application and having only that permission on my app, would limit my result ? Am I missing something here? Adding the app as an owner in the following way: Connect-AzureAD $objectIdOfApplicationToChange = Get-AzureADApplication -objectId "6929067b-b9ab-4bf6-bb17-81be5eb31ba1" $objectIdOfApplicationThatNeedsToBeAdded = Get-AzureADApplication -ObjectId "21780578-3035-47c1-8096-a1641ab3123d" Add-AzureAdApplicationOwner -ObjectId $objectIdOfApplicationToChange.ObjectId -RefObjectId (get-azureadserviceprincipal -all $true | where-object {$_.AppId -like $objectIdOfApplicationThatNeedsToBeAdded.AppId}).ObjectId When I query the Graph through PowerShell, I was hoping to get a 403 when querying all applications... Anyone tried to limit the result you get back using this permission ? It is not a wanted solution to give permissions to read all applications for this app, therefor we need to limit the access...8.8KViews0likes1CommentSet work location via API (Graph?)
Hi Graph Team! We would like to set the work location ("Office", "Remote") via Graph API endpoint. We want to synchronize the work location in Teams / O365 with information from our internal tool. This workaround here is not applicable to our use case: https://techcommunity.microsoft.com/t5/teams-developer/set-work-location-via-api-graph/m-p/3874804#M8092 There seems to be a high interest in this capability. Can you add this function to Microsoft Graph? Thanks! Jens3.8KViews2likes3CommentsMicrosoft Graph APi to create List item with PersonAndGroup
I'm trying to create a sharepoint list view item with one column of type personandgroup using graph API. The person or group is not part of sharepoint but its available in Microsoft 365. But Microsoft graph API creates item only when i pass PersonAndGroup value as sharepoint id if i try to pass claim it does not work. As users and groups have not logged in or connected "user Information List" does not have Users I'm trying to populate and not able to create a new List item. Following is working without any issue as long as user id exists in the "user Information List" var listItem = new Microsoft.Graph.ListItem { Fields = new FieldValueSet { AdditionalData = new Dictionary<string, object>() { {"UsernameLookupId", "14"}, //PersonAndGroup where I'm passing sharepoint user Id {"groupname", "Avengers"}, {"Title" , "Captain America"}, //Permission {"Role", "User" }, {"GroupId" , ""}, {"UserId" ,""} } } }; Is there anyway to populate lookup (personandgroup) value without sharepoint userid something like below var listItem = new Microsoft.Graph.ListItem { Fields = new FieldValueSet { AdditionalData = new Dictionary<string, object>() { {"Username", { "user": {"id": "{UserId}"} } } } };3.8KViews0likes3CommentsI can't find the DRIVE-ITEM-ID
Hello how are you? I managed the most complicated steps that would be authentication, but what I believed to be the easiest became an even greater challenge. When I access the graph developer https://developer.microsoft.com/en-us/graph/graph-explorer. I can't get to a specific excel sheet. I tried in several ways, I got the driveId,l driveItem, but the Drive-Item-Id I can't find at all. Even the file that I actually need to work I can't reach, only when I go to the "My recent files" endpoint. Would anyone have a suggestion on how to get the DRIVE-ITEM-ID of an excel sheet? I created an application, because the objective is to develop a web application in Python to connect our automations and this also involves connecting several APIs. Can anyone give me some help?3.7KViews0likes2CommentsHow to get last activity on all teams in my tenant?
Is it possible to get the last activity in a team from all teams in my tenant. I want this to determin what teams have not been active in a specific amount of days, so i can do some clean up work. But i can not find a way to get this info unless i use the teamsteamactivity report but that is only within last 180 days. I want the last update date on all teams. Can i do this?3KViews0likes2CommentsMialbox Forwarding in Graph API
Is there away to retrieve the ForwardingSmtpAddress and DeliverToMailboxAndForward settings for a mailbox via the Graph API? I'm building an application that aggregates information about a user from multiple sources, one of them being AzureAD/M365. We want to show a support engineer the forwarding information that is set on a user's mailbox, but it seems the only way to get this is via PowerShell, which means settings up a runspace and powershell remoting, which I'd rather not do, sense I'm using the graph API already for license information.2.8KViews1like2CommentsIs there any REST API for creating new Excel (.xlsx) file in OneDrive cloud
I'm trying to create a new excel file in OneDrive with the below properties of the REST API call. URL: https://graph.microsoft.com//v1.0/me/drive/root/children Body: { "name": "MyFile.xlsx", "file": {}, "@microsoft.graph.conflictBehavior": "rename" } Header: Content-Type:application/json With the help of the above properties, I'm able to create the file in OneDrive. But it is created without size & If I try to open the workbook it says Couldn't Open the Workbook Error The workbook cannot be opened. Basically, whenever I create a new excel file from UI it has a default size of 7.81KB (Could be used for metadata of file). I have taken reference from https://docs.microsoft.com/en-us/graph/api/driveitem-post-children?view=graph-rest-1.0&tabs=http Is there anyone who knows how to resolve this issue?2KViews1like3Comments