Forum Discussion
Uploading the CSV files to teams channel using python
- Jul 26, 2023
chetan_sk - yes, the second option i.e., using bot API, that limits to only personal scope. And as your intent to send files in team's channel you have to go with first approach only.
The file you intent to send must be already present in SharePoint. Once you fire the API query, it will send message with attachment directly in team's channel. (not as reference link to download the file)Thanks,
Prasad Das
------------------------------------------------------------------------------------------
If the response is helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link.
chetan_sk -
Using Graph API:
Post messages with file attachments that refer to existing SharePoint files, using the Graph APIs for OneDrive and SharePoint. To use the Graph APIs, obtain access to either of the following through the standard OAuth 2.0 authorization flow:
- A user's OneDrive folder for
personal
andgroupchat
files. - The files in a team's channel for
channel
files.
Graph APIs work in all Teams scopes.
Ref: Send chatMessage in a channel or a chat - Microsoft Graph v1.0 | Microsoft Learn
Using Teams Bot API:
Teams bot APIs work only in the personal
context. They don't work in the channel
or groupchat
context.
Using Teams APIs, the bot can directly send and receive files with users in the personal
context, also known as personal chats.
Ref: Send and receive files using bot - Teams | Microsoft Learn
Sample: Microsoft-Teams-Samples/samples/bot-file-upload/python at main ยท OfficeDev/Microsoft-Teams-Samples (github.com)
Thanks,
Prasad Das
------------------------------------------------------------------------------------------
If the response is helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link.
- chetan_skJul 26, 2023Copper Contributor
Prasad_Das-MSFT Thank-you for your response,
To summerise :
The second method which you mentioned Using Teams Bot API: works only when we have to send the message to particular user / person in the miscrosoft team and not to the particular channel or group.
That means for our user case, which is posting it to the teams channel or group we need to go ahead with the first approachUsing Graph API: where we send the message in the channel with the reference link to dowload the file from sharepoint and cant share the actual file.
So there is no direct way of posting the file to microsoft teams, it should always be uploaded to sharepoint, Correct if my understanding is wrong.
Also is there any reference for uploading the file to sharepoint via python ?
Regards,
Chetan
- Prasad_Das-MSFTJul 26, 2023
Microsoft
chetan_sk - yes, the second option i.e., using bot API, that limits to only personal scope. And as your intent to send files in team's channel you have to go with first approach only.
The file you intent to send must be already present in SharePoint. Once you fire the API query, it will send message with attachment directly in team's channel. (not as reference link to download the file)Thanks,
Prasad Das
------------------------------------------------------------------------------------------
If the response is helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link.