Forum Discussion
David_Chan2255
Nov 12, 2024Copper Contributor
Unable to download teams channel pasted image
Hi everyone, I got a composeExtension/fetchTask payload from messaging extension in teams channel. here is the messagePayload body {
"contentType": "html",
"content": "<p><i...
David_Chan2255
Nov 15, 2024Copper Contributor
1.Please share the steps you took to encounter the issue.
1. post a message with copy and pasted image to teams channel
2. right click on the message a select an action with an extension created
3. Teams bot send a POST request with composeExtension/fetchTask to our API
4. in the API, we get the URL of that image
5. try to download it with token.
2.Any specific documentation you followed that relates to your problem.
no.
Sayali-MSFT
Microsoft
Nov 18, 2024Hello David_Chan2255, Thank you for your report! We are currently unable to reproduce the issue you’re experiencing. Could you please provide the following information to help us better assist you?
- Please confirm the version of Teams you are using when encountering this issue.
- please share any relevant code snippets and manifest Json.
This information will be invaluable in helping us understand the problem and find a solution.
- David_Chan2255Nov 19, 2024Copper Contributor
Hello Sayali-MSFT,
thank you for the reply.
- Please confirm the version of Teams you are using when encountering this issue.
I am using Teams in web, I think that is the latest version.
- please share any relevant code snippets and manifest Json.
manifest JSON:
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.12/MicrosoftTeams.schema.json",
"version": "1.0.0",
"manifestVersion": "1.12",
"id": "6310e..aa72c23",
"name": {
"short": "Maximizer dot net www2",
"full": "Maximizer CRM Messaging dot net www2 Extension"
},
"developer": {
"name": "Maximizer",
"mpnId": "1..0",
"websiteUrl": "https://maximizer.com",
"privacyUrl": "https://www.maximizer.com/about-us/privacy-policy/",
"termsOfUseUrl": "https://www.maximizer.com/about-us/terms-of-use/"
},
"description": {
"short": "Boost sales productivity by quickly accessing and sharing key CRM data in chats.",
"full": "**Unlock the Full Potential of Your Sales Team with Maximizer's Messaging Extension for Microsoft Teams.**\r\n \r\nDesigned to streamline collaboration, this app allows users to quickly search for and share key CRM data, such as contacts, opportunities, cases, and leads, directly within Teams conversations. By bringing CRM data into your chat feed, you can make faster, informed decisions and keep your team aligned without leaving Teams.\r\n \r\n**Key Features:**\r\n \r\n- **Instant CRM Search:** Easily search and retrieve Address Book entries, Opportunities, Leads, and Cases directly within Teams.\r\n- **Seamless CRM Data Sharing:** Share Maximizer entries in Teams conversations so that your colleagues can access key information without switching apps.\r\n- **Quick CRM Data Access:** Open original Maximizer records from the contact cards shared with you in Teams.\r\n- **Effortless Communication Capture:** Save important chat messages and attachments to contacts, leads, opportunities, and cases in Maximizer.\r\n \r\nTo access the features of this app, a Maximizer subscription is required. To get started, please contact Maximizer to set up a trial account, or reach out to your Maximizer administrator for a license. For more information on purchasing a subscription, visit [Maximizer Website](https://www.maximizer.com/book-a-demo/) or contact support at [email address removed for privacy reasons](mailto:email address removed for privacy reasons)."
},
"icons": {
"outline": "outline.png",
"color": "color.png"
},
"accentColor": "#cdea1e",
"staticTabs": [
],
"composeExtensions": [
{
"botId": "f4593....a72d",
"commands": [
{
"id": "SaveMsg",
"type": "action",
"title": "Save to Maximizer",
"description": "Save to Maximizer",
"initialRun": false,
"fetchTask": true,
"context": [
"message"
],
"parameters": [
{
"name": "param",
"title": "param",
"description": "param",
"inputType": "Text",
"choices": []
}
]
}
],
"canUpdateConfiguration": false
}
],
"validDomains": [
"www.maximizer.com"
]
}
request payload from teams bot
{
"name": "composeExtension/fetchTask",
"type": "invoke",
"timestamp": "2024-11-15T05:57:45.317Z",
"localTimestamp": "2024-11-15T13:57:45.317+08:00",
"id": "f:0cede953-d6e6-786f-552e-e738c1f14677",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/ca/94b4884d-1dcf-4749-be8f-b3389397442b/",
"from": {
"id": "29:1eF0-vh4wgXY8RnFlamf4Q5jznu4BXVIh54nmwmLUQtSFcXge_jAt6ix_Zw3sagvbCLqqPJH7tpbxF3l1f1oN3Q",
"name": "David Chan",
"aadObjectId": "393b9500-1b76-4a83-a6cf-8b92bd5201a7"
},
"conversation": {
"isGroup": true,
"conversationType": "channel",
"tenantId": "94b4884d-1dcf-4749-be8f-b3389397442b",
"id": "19:qRth1o0KEf5ocyb2MXSiNTtE8gqFKoCCwKpi9I2sgZs1@thread.tacv2;messageid=1730769249935"
},
"recipient": {
"id": "28:f4593a6a-e609-4e62-bb44-1b3cf61ea72d",
"name": "msTeamsExtensionDotNetCoreWww2"
},
"entities": [
{
"locale": "en-US",
"country": "US",
"platform": "Web",
"timezone": "Asia/Hong_Kong",
"type": "clientInfo"
}
],
"channelData": {
"channel": {
"id": "19:qRth1o0KEf5ocyb2MXSiNTtE8gqFKoCCwKpi9I2sgZs1@thread.tacv2"
},
"team": {
"id": "19:qRth1o0KEf5ocyb2MXSiNTtE8gqFKoCCwKpi9I2sgZs1@thread.tacv2"
},
"tenant": {
"id": "94b4884d-1dcf-4749-be8f-b3389397442b"
},
"source": {
"name": "compose"
}
},
"value": {
"commandId": "SaveMsg",
"commandContext": "message",
"context": {
"theme": "default"
},
"messagePayload": {
"id": "1731310755026",
"replyToId": "1730769249935",
"createdDateTime": "2024-11-11T07:39:15.026Z",
"deleted": false,
"importance": "normal",
"locale": "en-us",
"from": {
"user": {
"userIdentityType": "aadUser",
"id": "393b9500-1b76-4a83-a6cf-8b92bd5201a7",
"displayName": "David Chan"
}
},
"body": {
"contentType": "html",
"content": "<p><img itemscope=\"png\" itemtype=\"http://schema.skype.com/AMSImage\" src=\"https://ca-prod.asyncgw.teams.microsoft.com/v1/objects/0-eca-d2-82060272c88cde4d9878dd71225698c5/views/imgo\" width=\"213\" height=\"164\" alt=\"image\" id=\"x_0-eca-d2-82060272c88cde4d9878dd71225698c5\" itemid=\"0-eca-d2-82060272c88cde4d9878dd71225698c5\"></p>\r\n<p>12313</p>"
},
"attachments": [],
"mentions": [],
"reactions": [],
"linkToMessage": "https://teams.microsoft.com/l/message/19:qRth1o0KEf5ocyb2MXSiNTtE8gqFKoCCwKpi9I2sgZs1@thread.tacv2/1731310755026?parentMessageId=1730769249935"
}
},
"locale": "en-US",
"localTimezone": "Asia/Hong_Kong"
}
- Sayali-MSFTNov 25, 2024
Microsoft
Hello David_Chan2255,
Implement error handling to capture and log the exact error message returned by the API. This can provide more insights into why the request is failing.Here is a sample code snippet to fetch the image using the Graph API token:
using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; public async Task<byte[]> DownloadImageAsync(string imageUrl, string accessToken) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); var response = await httpClient.GetAsync(imageUrl); if (response.IsSuccessStatusCode) { return await response.Content.ReadAsByteArrayAsync(); } else { throw new HttpRequestException($"Failed to download image. Status code: {response.StatusCode}"); } } }
Make sure to replace imageUrl with the actual URL of the image and accessToken with the valid Graph API token.