Cannot get a person by its id using ms-graph people API - microsoft-graph-api

I'm using the Microsoft Graph People API and when I look at the docs here you can get a person by using its id:
I use the Graph Explorer to get people with the following API call:
https://graph.microsoft.com/v1.0/me/people?$select=id
I successfully get a list of ids.
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users...",
"#odata.nextLink": "https://graph.microsoft.com/v1.0/me/people?$select=id&$skip=10",
"value": [
{
"id": "ddb9e9e4-a4cc-46ee-93f4-ba135920c84a"
},
{
"id": "37136f8b-33b3-4596-a63b-d41dc8edda34"
},
{
"id": "8c13d891-bd2f-42e5-8650-450b3318f8e3"
}
]
}
Then I use one of the ids to get more info about a single person by using this call:
https://graph.microsoft.com/v1.0/me/people/ddb9e9e4-a4cc-46ee-93f4-ba135920c84a
And I get an error:
{
"error": {
"code": "ErrorInternalServerError",
"message": "An internal server error occurred. The operation failed.",
"innerError": {
"request-id": "6e138441-5e1d-4f04-a87b-8141547cbb07",
"date": "2018-05-04T06:36:22"
}
}
}
Am I doing sth wrong ?

I'm also getting this error when following Microsoft's documenation.
As a workaround I added a filter.
https://graph.microsoft.com/v1.0/me/people?$filter=id eq 'ddb9e9e4-a4cc-46ee-93f4-ba135920c84a'
Unfortunately is seems that filtering by id is not supported at this time.
If you have the persons name you can use a filter like this:
https://graph.microsoft.com/v1.0/me/people?$filter=givenName eq 'Baris'
At the end of the day I prefer to use /users endpoint to get this type of information.
https://graph.microsoft.com/v1.0/users?$filter=id eq 'ddb9e9e4-a4cc-46ee-93f4-ba135920c84a'
or
https://graph.microsoft.com/v1.0/users?$filter=startswith(givenName, 'Baris')
Hope this helps!

Related

Teams Export API not allowing me to filter by channel

I'm trying to use the Teams Export API to export a single Teams channel. I have my permissions set up properly; if I make a request to
https://graph.microsoft.com/v1.0/teams/{TEAM_ID}/channels/getAllMessages (without specifying a filter), I get the paginated results of all of the channel messages on my team. If I copy the sample datetime filters in that documentation, I also get a successful response with the appropriate results.
A successful response gives me a list of messages. Each one shows a channelIdentity field, which contains a channelId (fields removed for readability):
{
"value": [
{
"channelIdentity": {
"teamId": "{TEAM ID}",
"channelId": "{CHANNEL ID}"
},
},
]
}
What I want is to use this channelIdentity/channelId field as a filter on the results, so that I can export just the messages from a single channel.
If I run GET https://graph.microsoft.com/v1.0/teams/{TEAM_ID}/channels/getAllMessages?$filter=channelIdentity/channelId eq '{CHANNEL ID}', I get an error:
{
"error": {
"code": "BadRequest",
"message": "The entity property 'channelIdentity/channelId' and operationKind 'Equal' is not allowed in $filter query.",
"innerError": {
"date": "2022-11-16T23:47:06",
"request-id": "...",
"client-request-id": "..."
}
}
}
This reads to me like I'm not allowed to use eq with this ID. If I try a 'starts with', I get a different error:
GET https://graph.microsoft.com/v1.0/teams/{TEAM_ID}/channels/getAllMessages?$filter=startswith(channelIdentity/teamId, '{CHANNEL ID}')
{
"error": {
"code": "BadRequest",
"message": "Only binary operation expressions are allowed.",
"innerError": {
"date": "2022-11-17T00:11:26",
"request-id": "...",
"client-request-id": "..."
}
}
}
I'm unclear on what this is trying to say - either the ID starts with that phrase or it doesn't; it seems like a binary expression to me.
Is there some other approach I should use to get these results filtered by channel ID?
This API is designed to export everything from a team for backup/archival scenario. So, filtering by a specific channel is not supported now.
If you wish you may suggest this feature on Microsoft Feedback portal.
Any reason why you don't use List Channel Messages?
You can then make a GET call against this URL:
"https://graph.microsoft.com/v1.0/teams/{teamid}/channels/{channel id}/messages"
Note - as per that link you will need to Request access:
https://learn.microsoft.com/en-us/graph/teams-protected-apis
One other method, if you are using Graph Explorer, is add the signed-in user to the team as an owner, and it will let you test this method, you just won't be able to call via an App Registration until you do fill out that form.

How to access shifts of a team? "Sorry, the team was not found, or you may not have access to it"

I would like to read a team's shifts using https://graph.microsoft.com/v1.0.
However i always fail with different errors and get contradicting server messages.
I send the API requests with Postman.
I am using Application authorization method. I think i have set all required Api permissions for my app.
I beleive i supply the correct headers, like:
Authorization
Content-Type
MS-APP-ACTS-AS
When i send the request like this to GET a team:
GET https://graph.microsoft.com/v1.0/teams/{id}
i get the following error message:
"error": {
"code": "NotFound",
"message": "No team found with Group Id {id}",
"innerError": {
"date": "2020-09-05T08:37:17",
"request-id": "id"
}
}
But when i try to create the team (from a group) like this:
PUT https://graph.microsoft.com/v1.0/groups/{id}/team
I get the error as follows:
"error": {
"code": "Conflict",
"message": "Team already exists",
"innerError": {
"date": "2020-09-05T08:33:33",
"request-id": "id"
}
}
When i try to make my actual call of interest, like:
GET https://graph.microsoft.com/v1.0/teams/{id}/schedule/shifts
That also fails with error:
{
"error": {
"code": "NotFound",
"message": "{\"error\":{\"code\":\"NotFound\",\"message\":\"Sorry, the team was not found, or you may not have access to it.\",\"details\":[],\"innererror\":{\"code\":\"TeamNotFound\"}}}",
"innerError": {
"date": "2020-09-05T08:59:55",
"request-id": "id"
}
}
}
Pleaset help me understand what i am doing wrong!
Thank you in advance!
Solved (itself).
So what was happening:
i created a team (directly or from a group).
created a schedule for the team.
get the schedule for the team, and see the response:
"enabled": false,
"provisionStatus": "Failed", (so not running or queuing or something)
"provisionStatusCode": "GraphResourceNotFound",
struggle few (like 4-5) days
without changing a thing, get the schedule showing:
"enabled": true,
"provisionStatus": "Completed",
"provisionStatusCode": null,
Maybe it would help others to see the possible wait time length or add a clarification about the provisionStatus field’s status progression.

Receiving 400s and 500s when attempting to get singleValueExtendedProperties

trying to add extended properties to calendar objects. I am able to create calendars with the following payload (Ruby syntax, payload is sent as a JSON):
name: build_calendar_name,
singleValueExtendedProperties: [{
id: "String {#{SecureRandom.uuid}} Name setting_id",
value: #setting_id.to_s
}]
I receive a 201 from this request and the calendar is created no problem
The frustrating part is I cannot retrieve the extended property when making a GET request. The following two requests should work:
GET /me/events/calendar_id?$expand=singleValueExtendedProperties($filter=id eq 'String {guuid} Name setting_id')
Response
{
"error": {
"code": "BadRequest",
"message": "Parsing OData Select and Expand failed: Found an unbalanced bracket expression.",
"innerError": {
"date": "2020-07-01T22:38:14",
"request-id": "<hidden>"
}
}
}
GET /me/calendars?$filter=singleValueExtendedProperties/Any(ep: ep/id eq 'String {guuid} Name setting_id' and ep/value eq 'setting_id')
Response:
{
"error": {
"code": "ErrorInternalServerError",
"message": "An internal server error occurred. The operation failed.",
"innerError": {
"date": "2020-07-01T22:40:15",
"request-id": "<hidden>"
}
}
}
Guuid, calendar_id and setting_id are dummy values, real values are used when attempting these calls.
We've also tried following the examples verbatim at this link https://learn.microsoft.com/en-us/graph/api/singlevaluelegacyextendedproperty-get?view=graph-rest-1.0&tabs=http#example and still receive these response codes. Would love some help with this. Thanks!
I reproduced this for the $expand case in Graph Explorer. The problem seems to be the = inside the parentheses. If you URL-encode that to %3D the query works fine.
$expand=singleValueExtendedProperties($filter%3Did eq 'String {guuid} Name setting_id')
For the $filter, I reproduce it when doing GET /me/calendars, but not when doing GET /me/events. This seems to be a problem with the service (unless the docs are just wrong). Let me check and report back.

Experiencing "404-unknown error" when attempting to lis team channel tabs with Graph

For a given team I want to choose a specific channel and list the tabs for the channel.
Using x to censor IDs:
I am able to use the following HTTP GET call to view the group:
https://graph.microsoft.com/v1.0/groups/193cexxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
And the following allows me to view the specific channel:
https://graph.microsoft.com/v1.0/groups/193cexxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
/team/channels/19:xxxxxxxxxxxxxxxxxxxxx#thread.skype/
The result looks like this:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups('193cee12-xxxx-xxxx-xxxx-a8022fe6754c')/team/channels/$entity",
"id": "19:xxxxxxxxxxxxxxxxxx#thread.skype",
"displayName": "General",
"description": "Test ",
"email": "",
"webUrl": "https://teams.microsoft.com/l/channel/19%xxxxxxxxxxxxxxxxxxx%40thread.skype/General?groupId=193cee12-xxxx-xxxx-xxxx-a8022fe6754c&tenantId=d02b4c26-xxxx-xxxx-xxxx-0e19a90257d6"
}
The error occurs when I try to access any properties of the channel:
https://graph.microsoft.com/v1.0/groups/193cexxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
/team/channels/19:xxxxxxxxxxxxxxxxxxxxx#thread.skype/tabs
The error looks like this:
{
"error": {
"code": "UnknownError",
"message": "",
"innerError": {
"request-id": "1b1040df-xxxx-xxxx-xxxx-04c7952674ba",
"date": "2019-11-04T11:xx:xx"
}
}
}
I am a group Owner.
There is no error message so it's hard to figure out what goes wrong. Has anybody else experienced this?
To get the information about the channels, you need to use the teams segment instead of the groups segment.
\/ -- 'teams' here, not 'groups'
/v1.0/teams/193cexxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/channels/19:xxxxxxxxxxxxxxxxxxxxx#thread.skype/tabs
https://learn.microsoft.com/en-us/graph/api/teamstab-list?view=graph-rest-1.0

Unable to filter messages by recipient in Microsoft Graph Api. One or more invalid nodes

I am trying to get a list of messages that are filtered by recipient from Microsoft Graph API. The url I am using for the request is:
https://graph.microsoft.com/beta/me/messages?$filter=toRecipients/any(r: r/emailAddress/address eq '[Email Address]')
But I am getting this is the response:
{
"error": {
"code": "ErrorInvalidUrlQueryFilter",
"message": "The query filter contains one or more invalid nodes.",
"innerError": {
"request-id": "7db712c3-e337-49d9-aa8d-4a5d350d8480",
"date": "2016-09-28T16:58:34"
}
}
}
A successful request should look like this (with a lot more data that I have omitted).
{
"#odata.context": "https://graph.microsoft.com/beta/$metadata#users('99999999-9999-9999-9999-999999999999')/messages",
"#odata.nextLink": "https://graph.microsoft.com/beta/me/messages?$skip=10",
"value": [
{
"toRecipients": [
{
"emailAddress": {
"name": "[Name]",
"address": "[Email Address]"
}
}
],
}
]
}
The request works if I remove the filter, and I am able to perform requests with simpler filters.
Is there a problem with my URL, or is there another way to make the request?
Another way to make the request might be to not use filter and use search instead, depending on exactly what you want (and you may have already tried this):
https://graph.microsoft.com/beta/me/messages?$search="to:[Email Address]"
After several hours looking for the solution, I found in the office365 documentation that the property toRecipients is not filterable:
https://msdn.microsoft.com/en-us/office/office365/api/complex-types-for-mail-contacts-calendar#MessageResource
I guess that it's the same in the graph api. So the only solution is using search.

Resources