MS Graph Issue with a get filesfolder for a teams channel - microsoft-graph-api

I've written a program using the MS Graph REST API that sends a message to a channel with a file attached to the message using delegated permissions.
It works fine using my Office 365 account and have used it with a couple of customers without issue.
Using it at a new customer, I am getting the following error.
But, I am able to upload a file to the Channel Folder manually in the Teams App without issue.
Error:
Attempting to retrieve the Channel Folder for 19:ca8d4ccaaesdgsdfhsdaa40cc9e3b3677c75dc85f#thread.skype
Response Message: Not Found
Caught: java.lang.Exception: Failure getting the Channel Folder: {"error":{"code":"NotFound","message":"
https://mycustomer.sharepoint.com/db905278f90cd6f8c0b9e56bb0da6deb2c6a41cf312ab56b9d319b8c55252545ce3e407/978d84225552125552a37b5248a1926dd7fcf3cb7300a2fd01989ebdf009671400c250
Site isn't available. Attempting to create site : False.","innerError":{"date":"2021-05-28T21:48:31","request-id":"2752264b4d-2031-4d03-962e7-aeb1ccb4617a5","client-request-id":"2752264b4d-2031-4d03-962e7-aeb1ccb4617a5"}}}
java.lang.Exception: Failure getting the Channel Folder: {"error":{"code":"NotFound","message":https://mycustomer.sharepoint.com/db905278f90cd6f8c0b9e56bb0da6deb2c6a41cf312ab56b9d319b8c55252545ce3e407/978d84225552125552a37b5248a1926dd7fcf3cb7300a2fd01989ebdf009671400c250 Site isn't available. Attempting to create site : False.,"innerError":{"date":"2021-05-28T21:48:31","request-id":"27564b4d-2031-4d03-96e7-aeb1cb4617a5","client-request-id":"27564b4d-2031-4d03-96e7-aeb1cb4617a5"}}}
Code Snippet:
Request folderRequest = new Request.Builder()
.url("https://graph.microsoft.com/v1.0/teams/${teamId}/channels/${channelId}/filesFolder")
.method("GET", null)
.addHeader("Authorization", "Bearer ${token}")
.build();
Response response = client.newCall(folderRequest).execute();
println "Response Message: " + response.message();

This call fails with a 404 response when a new team/channel is created via the Graph API. This happens because the channel files folder is not created when creating a Team/Channel. By design unless the user initiate the file tab the graph API will throw the error.
The issue described above is resolved if a user clicks on the 'Files' tab. Post initialization, try again after sometime and observe result.

Related

My app is not able to send message to Teams channel using graph api

I am trying to send message to teams channel using graph api. I am able to send the messages using my personal(user) tokens but not able to do it using an app which I have registered in Azure portal. My app also got access to protected apis from Microsft Teams.
Attaching the screen shot of app permissions and code snippet on how I am getting tokens.
app permissions
Code snippet to get tokens
One thing I noticed, when I decoded the the tokens I am getting, that roles in tokens only shows application permissions("Teamwork.Migrate.All") and it doesn't show delegated permissions("ChannelMessage.Read.All","ChannelMessage.Send","Teamwork.Migrate.All").
Below are the error message I am getting.
While doing get request to https://graph.microsoft.com/v1.0/teams/{teams_id}/channels/{channel_id}/messages
one of 'ChannelMessage.Read.All' or 'ChannelMessage.Read.Group' when using resont. Roles on the request 'Teamwork.Migrate.All' and resource specific consent g request ''", 'innerError': {'date': '2021-07-04T14:27:41', 'request-id': '8c1f-e345bf15da7b', 'client-request-id': '8c1fffc2-c94d-4d5b-a81d-e345bf15da7b'}}}
While doing post request to https://graph.microsoft.com/v1.0/teams/{teams_id}/channels/{channel_id}/messages/{message-id}/replies
{'error': {'code': 'Unauthorized', 'message': 'Unauthorized', 'innerError': {'d4:26:47', 'request-id': '44fe99be-1ed8-4505-a3e7-a88ce934e3f8', 'client-request8-4505-a3e7-a88ce934e3f8'}}}
You are currently using Get access without a user(Application permission). Application permissions are only supported for migration. Instead you should try delegated flow: Get access on behalf of a user. Please go though the documentation and you can try it using Postman or Fiddler.
You can also try Get started with Microsoft Graph and Python tutorial which shows fetching calendar information using Graph APIs.

O365 Graph, strange error on message download on some mailboxes, not all

i have hundreds of users using my wpf app to download O365 messages (using c# Graph SDK), since some weeks small portions are having error on 1 or more mailboxes when downloading message.
The error returned by Graph sdk in c#:
ErrorInternalServerError Message: An internal server error occurred. The operation failed. ClientRequestId: 54e9e307-1a60-4f78-9f8f-5def1c6fb5b5
As i can't reproduce the problem on my side, it is very hard to find the problem, here some information:
A user can have 20 mailboxes and only 1 or 3 are no more working
The problem is only on downloading messages, the OAuth connection is working fine, i can get the list of folders, the number of messages in the folder,...
When the user deletes and re-create the email box in O365 it will work again
If the user connects with IMAP instead of Graph it works fine!
Here the code i use to download MIME message (which works fine since many months):
var _request = m_graphClient.Users[m_Account.Server_EmailAddress].Messages[pMessageID].Request().GetHttpRequestMessage();
_request.RequestUri = new Uri(_request.RequestUri.OriginalString + "/$value");
var _response = await m_graphClient.HttpProvider.SendAsync(_request);
With same result i tried also:
var _responseStream = await m_graphClient.Users[m_Account.Server_EmailAddress].Messages[pMessageID].Content.Request().GetAsync();
The problem sounds like there is an O365 mailbox update rolling, i have more and more users having this problem suddenly.
I hope you can guide me to find the problem.
Thank you very much.

MS Graph API Error: 'Failed to execute Skype backend request GetThreadsS2SRequest

I'm getting the following error message.
Failed to execute Skype backend request GetThreadsS2SRequest
when trying to Add, Update or Delete channels using MS Graph API for Teams. The calls were working fine for a while but now suddenly this error comes up. This happens particularly when the channel type is private. Any help would be much appreciated. Thanks.

Microsoft Graph API - MailboxNotEnabledForRESTAPI 404 error on beta/users/{id}/photo

I am trying to fetch users profile photo using the beta endpoint beta/users/{id}/photo of the Microsoft Graph API
but I get a 404 MailboxNotEnabledForRESTAPI error
error: {
code: 'MailboxNotEnabledForRESTAPI',
message: 'REST API is not yet supported for this mailbox.'
...
The error does not make sense because I am trying to access Azure Ad profile picture which should not have anything to do with mailbox.
Would anyone know if I am missing something?
The endpoint you're using says the following about getting a user picture:
Note: When attempting to GET a user photo, this operation first attempts to retrieve the specified photo from Microsoft 365. If the photo is not available in Microsoft 365, the API attempts to retrieve the photo from Azure Active Directory.
Historically the user profile picture was stored in the Exchange server, apparently they are now also saving the image somewhere else.
To check your issue, I've added a picture to a user that doesn't have any license. And started trying requests in the Graph Explorer
Request to v1.0/users/upn_here/photo ❌ failed with ResourceNotFound -> Resource could not be discovered.
Request to beta/users/upn_here/photo ✔ gives me information about the image (eg. size)
Request to v1.0/users/upn_here/photo/$value ❌ failed with ResourceNotFound -> Resource could not be discovered.
Request to beta/users/upn_here/photo/$value ✔ gives me the image. (I see the picture I uploaded before).
You should check the used access token, copy the token and paste it here https://jwt.ms (Microsoft owned page to show you the data in the token).
According to the docs you'll need at least the delegated User.Read scope or the application scope User.Read.All.

PowerApps Custom Connector returns 404 in app builder

I'm trying to create a connection to an external OData API from PowerApps.
I've created a custom connector via a Postman collection - the custom connector appears to work correctly in test mode but as soon as I try to consume it in the PowerApp I always get a 404 error popup in the expression editor.
Checking the POST request made to https://europe-001.azure-apim.net/invoke and re-playing it with all headers via Postman results in the same 404 error:
{
"statusCode": 404,
"message": "Resource not found"
}
Testing the API in the PowerApps Swagger editor comes back with the results, but instead of a POST to the above URL where headers are sent with the API endpoint address, a GET is made instead.
If I replay this GET request with the same headers etc, I get the same 404. The only thing that changes per request is x-ms-client-request-id so I assume this is to prevent XHR replays.
Am I missing some publishing step for my custom connector?
Has anyone got something like this working?
Edit:
Interestingly - I tried this with a basic API at jsonplaceholder.typicode.com and this works. The API requires no auth and returns data to my Powerapp without an issue.
I'm not sure why this is different from the other custom connector apart from the authentication mechanism.
Edit edit:
This may be a bug in PowerApps - MS support are looking into it for me and another user stated their connectors stopped working since the October release with the same error.

Resources