Forum Discussion
barun69
Dec 05, 2019Copper Contributor
Sending a message to microsoft teams bot using python
I have created a bot and subscribed it to Microsoft Teams, I have done all the configuration settings such that I am getting all the messages to my web-app from MSTeams.
Following to this documentation, I am trying to hit an Http post request to send the reply message to the same bot. But I am getting 401 i.e unauthorized error. Maybe I am not getting the correct token. could someone help me telling how can we generate the token in order to do an Http request to the MSTeams?
below is the code snippet that I am using.
team_message = json.loads(request.data.decode("utf-8"))
conversion_id = team_message.get("conversation").get("id")
activity_id = team_message.get("channelData").get("clientActivityID")
service_url = team_message.get("serviceUrl")
url = service_url + "/v3/conversations/{}/activities/{}".format(conversion_id, activity_id)
res = requests.post(url=url, headers={"Authorization": "Bearer abcdfjkdsa")
- subhasish-MSFT
Microsoft
barun69 ,
Can you please share how did you generate the Bearer Token? It has to be a valid access token.