How to access shared sharepoint files from ms teams bot activity context - sharepoint

I want to process a file "sent" via ms teams in a personal chat with an ms teams bot app. However only uploaded files appear in the activity not "linked" files from a sharepoint folder shared with onedrive.
click the attachment icon, select onedrive, select a file from a shared folder to be linked:
https://i.stack.imgur.com/iDGc4.png
https://i.stack.imgur.com/HW5xT.png
bot receives an activity with the following attachments:
context.activity.attachments has the value
[{contentType: 'text/html', content: '<p>test </p>'}]
How can I know which link the user has sent? Is there maybe another event I can listen to to know which file the user linked?
When I upload a new file instead of using one from the shared sharepoint folder then each context.activity.attachments contains a content.downloadUrl from which I can download the file just fine.

Related

Handling Error in Teams when there is no SharePoint app uploaded in app catalogue

I am having a SharePoint solution that is uploaded to the tenant app catalog. For the same SharePoint solution, I have the TeamsPackage .zip file which can be uploaded to Microsoft Teams and the app will load successfully.
But if I am not having my SharePoint Solution app uploaded to the tenant app catalog, and I try to upload the TeamsPackage .zip file to Microsoft Teams then I get a 404 error and there is no way for me to do error handling and present a custom message to the end user.
I am not using any client secrets or application Ids.
Note:- This is for a static personal app only.
Steps to reproduce the behavior:
Create a hello world SPFx teams solution
After compiling it you will get the SharePoint package (.sppkg) and teamspackage .zip file.
Go To Microsoft Teams and upload a custom app, select the teamspackage .zip file and then add it.
Expected behavior
As below in the screenshot, we get a default error by Microsoft teams, but here I need to give my own custom message to the user.
enter image description here

Can't delete Sharepoint folders created by Microsoft Graph API but can delete ones created in web browser

I can delete files and folders created directly in SharePoint and Teams via web browser or desktop app.
But when I create a folder via Microsoft Graph API, the delete option is not shown in the drop down menu in the web browser or desktop app, and when I try to delete that folder using the Microsoft Graph API I get a 403 Error (a permission issue, I believe).
I'm an owner of the team/site with read and write permissions.
Here's the API info used to create the folder:
POST /groups/{group-id}/drive/items/{parent-item-id}/children
BODY
{
"name": "1 Proposal",
"folder": { },
"#microsoft.graph.conflictBehavior": "rename"
}
And the one to delete:
DELETE /groups/{group-id}/drive/items/{item-id}
Is there something I should put in the body when creating the folder to help with permissions (inherited from parent folder or something)?

How to differentiate microsoft teams channel folder and normal SP folder in sharepoint document library

I'm trying to get the Microsoft Teams channel's folders using SharePoint rest API, but i'm getting all folders in the document library. How to differentiate b/w MS-Teams channel's folder and normal SP folder.
There are no differences in Share Point folder which are create for channels. Only way for you to identify folder would be to match channel names but it's not reliable as when channel name is changed SharePoint folder name does not change.

accessing files and folders other than sharepoint site's default shared documents using office365 api

Working on windows store apps:
I am trying to access the files and folders of office365 documents library.
I can access the one drive documents as described in this link Common file tasks using the Office 365 client library
But it do not provide a way to access the files and folders in other than onedrive document library.
e.g [https://my-office365-tenant.sharepoint.com/mysite/mydocumentslibrary]
However i had tried a way and it do get the files and folders other than onedrive.
I had not used any capability i created SharePointClient as given below:
var client = new SharePointClient(new Uri("https://my-office365-tenant.sharepoint.com/mysite"),
async () => await AcquireTokenAsync(AuthenticationContext, "https://my-office365-tenant.sharepoint.com"));
IPagedCollection<IItem> items = await client.Files.ExecuteAsync();
In this way i get the files of default "Shared Documents" document library inside "mysite", but i want to get the files and folders of another documents library "mydocumentslibrary" inside same site "mysite".
Can anyone please guide me how to do that or am i missing something? or there is anyother way to do this using office365 api only.
I just went through the documentation of this new API, it seems the file operation is limited to the one drive, I doubt you can get file in another document library.
To get files in other document library, as you're developing windows store APPs, you can SharePoint mobile object model or REST APIs:
Overview of the SharePoint 2013 mobile object model
Get started withthe SharePoint 2013 REST service
The APIs allows access only to default document library. Example:
OneDrive for Business: https://{tenant}-my.sharepoint.com/_api/v1.0/me
SharePoint sites: https://{tenant}.sharepoint.com/{site-path}/_api/v1.0

Sharepoint Online DocumentSharing API

trying to share a file with external users via the API, our in-house app will upload the file to sharepoint, return the view only link and we can then send that link to external users avoiding emails etc.
Is this possible with .NET C#?
Yes, it is possible. with the SharePoint client object model, your application can: Upload the document to the document list, and set the permission for that item, then return the link to external user.

Resources