developer
124 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#?Solved65KViews0likes3CommentsSharePoint 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.9KViews0likes5CommentsVariable in Graph Request Body (PowerShell)
Working off the following URL: https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fgraph%2Fapi%2Fpasswordauthenticationmethod-resetpassword%3Fview%3Dgraph-rest-beta%26tabs%3Dhttp&data=04%7C01%7CJonesL%40duvalschools.org%7C997660b94b6e446de25508d9370bfc97%7C8deb1d4dd0a44d0489aef7076cbaa9fb%7C1%7C0%7C637601346885178418%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=ZVLJ3SH%2FHpLXNgV1uJAZqdCpLfvKqy%2Bb3kn7epZeUDA%3D&reserved=0 When I execute the following command in my PowerShell script it works flawlessly $PWCBody = '{ "newPassword" : "ssd$$FGW!!", "forceChangePasswordNextSignIn" : true }' $PWCURI = "https://graph.microsoft.com/beta/users/XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/authentication/passwordMethods/XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resetPassword" $PWChange = Invoke-RestMethod -Uri $PWCURI -Headers $HeaderDelegate -body $PWCbody -Method POST -ContentType "application/json" However, when I change the Request Body newPassword to variable I get a (403) Bad Request. $PWCBody = '{ "newPassword" : $password, "forceChangePasswordNextSignIn" : true }' How can i handle a variable in a Requested Body that's surrounded by single quotes? Thank You, -LarrySolved6.4KViews0likes7Commentsgraph api to get all files from all team channels based on user access
I am trying to find an api using which I can get all files from all the teams/channels where particular user has access to. I tried/used microsoft search api for files. but that return all files based on delegate access token user not specific to a particular user For e.g:- If I generate delegate token using "sgupta" but now I have to use the api to find all the files accessible to "abhishek" . I can't achieve it. I profiled the microsoft teams. they are grabbing all team site urls to get the files but that is not efficient call for a large organization https://teams.microsoft.com/api/mt/apac/beta/teams/recent/files/aggregatefiles4.1KViews0likes1CommentMicrosoft Graph Explorer Update – Revamped and Expanded
In its previous version, Graph explorer had a limited set of capabilities that didn’t allow developers to fully discover and leverage all that Microsoft Graph has to offer. Today we are happy to announce lots of cool functionality that we enabled during our internship! Now you can: - Learn about what the Microsoft Graph has to offer with a cool autocomplete feature built in the request builder. - Access and use the Graph explorer, regardless of disability. - Use the Graph Explorer even if you do not have an Office 365 account, by accessing sample data. - Use your personal Microsoft Account to log-in to the Graph Explorer; it previously only supported work and school accounts. - Access the Graph explorer with a work or school account, even if you are not an organizational administrator. - Review and return to past queries. - Customize your request headers to allow in-depth testing. Learn more about the lastest updates: https://dev.office.com/blogs/microsoft-graph-explorer-update4KViews2likes0CommentsSet 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.8KViews2likes3CommentsI 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?3KViews0likes2CommentsWebhook (aka Subscription) for groups ressource changeType = created not working
HI, I'm looking for an fast and efficiant way to get notified for new AAD groups (unified groups to be exact). I could us the groups endpoint and then do a delta query every 5 minutes. But this is not "instant". MS Graph offers their implementation of webhooks (subscriptions) to solve this problem. I've checked the github repo: https://github.com/microsoftgraph/aspnet-webhooks-rest-sample And it works as designed for user email messages. I've modifed the code to get a subscription for groups. Currents these are only available in the /beta version. So I changed all URL and the message example is working on the beta version. Then I changed the subscription from messages to groups. But the sample refused to work. I tried the same request using the MS Graph Explorer but also failed due to this message: { "error": { "code": "InvalidRequest", "message": "Invalid 'changeType' attribute: 'created'.", "innerError": { "request-id": "9b786de2-1780-4ccf-9d1a-1243d0435ce1", "date": "2017-09-14T13:37:33" } } } The message is indicating that "created" is not supported :( The same request with "updated" is working as expected :( Permissions for the app are updated with Group.Read.All as the docs states. This is the request: { "changeType": "created", "clientState": "ca07f995-5f94-4a7a-903a-a6f9deb517e4", "notificationUrl": "https://gkm-msgraph-webhook.azurewebsites.net/notification/listen", "resource": "groups", "expirationDateTime": "2017-09-14T13:09:26.8315691+00:00" } The docs are suggesting it should work (I know it is the beta hive). Any idea? These are the docs: https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/subscription_post_subscriptions2.9KViews0likes4CommentsGraph API Object Schema
We're currently building an API in Mulesoft to update our Azure AD with new and updated user information from our HR system. Is there any documentation or a repository with the JSON schema for the different objects that the Microsoft Graph API works with. I've looked on the internet and GitHub, but have come up empty so far. We're currently using responses from the graph explorer to infer the schema, but I'm sure there is a better/more accurate way to find this. The preference would be to find the object schemas in Swagger 2.0 or 3.0 or better yet, RAML, but I'll take what I can get at this point.Solved2.9KViews0likes1Comment