Post Image to Teams channel from local path using python.

mounika anamalamuri 1 Reputation point
2022-08-16T08:27:48.157+00:00

I am trying to post an image(.png) to Microsoft teams channel using webhooks but i am seeing
empty box in channel instead of image using below code.
Please let me know if there any solution to fix this.

import asyncio
import pymsteams
myTeamsMessage = pymsteams.async_connectorcard("webhook url")
myMessageSection = pymsteams.cardsection()
myMessageSection.addImage(filepath)
Section1 = pymsteams.cardsection()
Section1.text("My First Section")
myTeamsMessage.addSection(Section1)
myTeamsMessage.send()

Microsoft Teams Development
{count} votes

2 answers

Sort by: Most helpful
  1. Meghana-MSFT 4,116 Reputation points Microsoft External Staff
    2023-07-27T07:47:04.2733333+00:00

    pymsteams is not a supported library from Microsoft, its a 3p library. As a workaround can you please try and use without pymsteams and see if that works. Please try using curl/powershell - https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using?tabs=cURL#send-messages-using-curl-and-powershell

    Thanks, 

    Meghana

    ************************************************************************* 

    If the response is helpful, please click "Accept Answer" and upvote it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.  

    0 comments No comments

  2. Meghana-MSFT 4,116 Reputation points Microsoft External Staff
    2023-07-27T07:47:10.66+00:00

    pymsteams is not a supported library from Microsoft, its a 3p library. As a workaround can you please try and use without pymsteams and see if that works. Please try using curl/powershell - https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/connectors-using?tabs=cURL#send-messages-using-curl-and-powershell

    Thanks, 

    Meghana

    ************************************************************************* 

    If the response is helpful, please click "Accept Answer" and upvote it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.  

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.