How can I store a file in Microsoft Teams via webservice?
Hi William,
I've done this previously using the following method with the Microsoft Graph API:
Note:You can use the Microsoft Graph API to upload files till 4 MB.Teams is associated with SharePoint and you can create folders in both. In MS Teams open the Team you want to use and select "Open in SharePoint". In SharePoint you can check the URL easily.1- Register an application in the Microsoft Azure PortalHere you get:Application (client) IDDirectory (tenant) IDObject IDClient secret2 - Consume the following REST web service to get a token:Add API Method: https://login.microsoftonline.com/{tenant}/oauth2/v2.0/tokenHTTP Method: POSTRequest Format: Form URL EncodedResponse Format: JSONIn URL: {tenant} = [tenant ID from Azure]Request Headers: "Content-Type" = "application/x-www-form-urlencoded"Body Content: client_id=[from Azure] &scope=https://graph.microsoft.com/.default &client_secret=[from Azure] &grant_type=client_credentials3 - Consume Microsoft Graph API REST:3.1 - Get site ID:Add API Method: https://graph.microsoft.com/v1.0/sites/{hostname}:/sites/{path}?$select=idHTTP Method: GETResponse Format: JSONRequest Headers: "Authorization" = [token_type] + " " + [access_token] (from the Token response)In URL: {hostname} = "heiway.sharepoint.com" {path} = [path to the Main folder in SharePoint]3.2 - Get Drive ID:Add API Method: https://graph.microsoft.com/v1.0/sites/{siteId}/driveHTTP Method: GETResponse Format: JSONRequest Headers: "Authorization" = [token_type] + " " + [access_token] (from the Token response)In URL: {siteId} = [Id from the response of the "Get site ID"]3.3 - Get Folder Path ID:Add API Method: https://graph.microsoft.com/v1.0/drives/{driveid}/root:/{itempath}HTTP Method: GETResponse Format: JSONRequest Headers: "Authorization" = [token_type] + " " + [access_token] (from the Token response)In URL: {driveid} = [Id from the response of the "Get Drive ID"] {itempath} = [sub-folder where to store the File]3.4 - Put the File in the Folder:Add API Method: https://graph.microsoft.com/v1.0/drives/{driveid}/items/{parentid}:/{filename}:/contentHTTP Method: PUTRequest Format: BinaryResponse Format: JSONRequest Headers: "Authorization" = [token_type] + " " + [access_token] (from the Token response)In URL: {driveid} = [Id from the response of the "Get Drive ID"] {parentid} = [Id from the response of the "Get Folder Path ID"] {filename} = [name of the file to upload]Request: [File binary content]
thanks Miguel,
your solution worked just fine!!
J Miguel Garcia wrote:
Hello,
I never did that, but you probably can get the API from microsoft teams page in order to use those services. Did you have them already?
You've some documentation here:
https://docs.microsoft.com/en-us/graph/teams-concept-overview
If your looking for something similar in code take a look at these modules which are accessing Planner which uses the same groups permissions.
https://www.outsystems.com/forge/component-overview/6927/ms-planner-connector
https://www.outsystems.com/forge/component-overview/6984/app-feedback-to-ms-planner-traditional