Use a program to load files into files tab in channel

Copper Contributor

We are trying to adapt a web app into Teams. I want to be able to read a combination of SQL Server data and flat files. Based on this data I want to do the following:

  1. Create a new channel in a specified team.
  2. Add a post to the Posts tab of the channel.
  3. Add a Note to the Note tab of the channel
  4. Copy files to the Files tab in the channel

Can someone get me pointed in the right direction?

1 Reply

@MihaIvan - 

You can use Microsoft Graph API to achieve your requirement. The Graph API allows you to interact with Teams data, including creating channels, posting messages, and managing files.

Create a new channel in a specified team:

You can use the POST /teams/{id}/channels endpoint to create a new channel in a specified team. 

POST https://graph.microsoft.com/v1.0/teams/{id}/channels
Content-Type: application/json
{
  "displayName": "Channel Name",
  "description": "Channel Description"
}

Add a post to the Posts tab of the channel:

To add a post to the Posts tab of the channel, you can use the POST /teams/{id}/channels/{id}/messages endpoint. 

POST https://graph.microsoft.com/v1.0/teams/{id}/channels/{id}/messages
Content-Type: application/json
{
  "body": {
    "content": "Hello, World!",
    "contentType": "text"
  }
}

Add a Note to the Note tab of the channel:

You'll need to use the OneNote API to create a new page in the notebook associated with the channel. 

POST https://graph.microsoft.com/v1.0/me/onenote/sections/{id}/pages
Content-Type: application/json
{
  "title": "Page Title",
  "content": "<h1>Page Title</h1><p>This is a page.</p>"
}

Copy files to the Files tab in the channel:

The Files tab in a channel is backed by a SharePoint document library. You can use the SharePoint API to upload files to this library. 

PUT https://graph.microsoft.com/v1.0/sites/{site-id}/drive/items/{item-id}:/filename:/content
Content-Type: text/plain
@odata.type: #microsoft.graph.driveItem
{
  "@microsoft.graph.sourceUrl": "http://localhost/myfile",
  "name": "myfile",
  "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. Click here to escalate.