Sending attachments to ms teams from an external bot framework

Sending attachments to ms teams from an external bot framework
1

Upvotes

Upvote

 Feb 26 2023
3 Comments (3 New)
New

Hello, 

 

I am using microsoft Bot SDK v3 framwork. I tried sending attachments to the msteams from the external bot framework, first by uploading the attachment to the sharepoint and then used the downloadUrl and id of the attachment in the payload as mentioned in this link https://learn.microsoft.com/en-us/microsoftteams/platform/resources/bot-v3/bots-files.

I am getting error statusCode 400 and bad request sent 

 

 payload: 

{
  "attachments": [{
    "contentType": "application/vnd.microsoft.teams.file.download.info",
    "contentUrl": "https://contoso.sharepoint.com/personal/johnadams_contoso_com/Documents/Applications/file_example.txt",
    "name": "file_example.txt",
    "content": {
      "downloadUrl" : "https://download.link",
      "uniqueId": "1150D938-8870-4044-9F2C-5BBDEBA70C9D",
      "fileType": "txt",
      "etag": "123"
    }
  }]
}

 

 

I used the curl https://graph.microsoft.com/v1.0/drives/:driveId/root:/doc1/Samplepdf.pdf:/content 

for uploading the attachment to the sharepoint by generating the access token. Can someone help me with this?

@Pernille-Eskebo @MicrosoftTechCommunity @msteams

Comments
Copper Contributor

I tried using the api, when I send only text message, it is working fine, when I add the attachment payload as mentioned in the documentation https://learn.microsoft.com/en-us/microsoftteams/platform/resources/bot-v3/bots-files

{
  "attachments": [{
    "contentType": "application/vnd.microsoft.teams.file.download.info",
    "contentUrl": "https://contoso.sharepoint.com/personal/johnadams_contoso_com/Documents/Applications/file_example.txt",
    "name": "file_example.txt",
    "content": {
      "downloadUrl" : "https://download.link",
      "uniqueId": "1150D938-8870-4044-9F2C-5BBDEBA70C9D",
      "fileType": "txt",
      "etag": "123"
    }
  }]
}

, I am facing the issue the issue 

{
    "error": {
        "code": "BadArgument",
        "message": "Unknown attachment type"
    }
}

 

the api I used to send messages to the msteams is https://smba.trafficmanager.net/amer/v3/conversations/a****/activities

 

 

I just wanted to clarify, in the payload download url is the url which we get by the PUT API for 

https://graph.microsoft.com/v1.0/drives/:driveId/root:/doc1/sample3.txt:/content

and passing attachment as a binary file, in the reesponse I am getting 

@microsoft.graph.downloadUrl (considering this as the downloadUrl ) and 
webUrl (considering this as the contentUrl ). Please correct me if I am wrong and I need help for this issue.
 
Thanks
 

 

 

Copper Contributor

I am able to send attachments to the ms teams channel from the bot framework, but the attachments are not rendering properly, I think there may be issue with my contentUrl and downloadUrl. I got the downloadUrl from the PUT api (https://graph.microsoft.com/v1.0/drives/:driveId/root:/doc1/pdfsample.pdf:/content), I replaced the driveId with my driveId, and contentUrl from the onedrive shareUrl. 

 

Can someone please help with this

 

@MicrosoftTechCommunity @msteams @Meghana-MSFT

Microsoft

@Abhijeethmodi - I am looking into this issue. Meanwhile, could you please move your question under Teams Developer so that our trackers could record this query for tracking further responses.