Send a (non-reply) message error 401 Unauthorized

Devinca Limto 6 Reputation points
2022-09-09T06:48:18.327+00:00

Hi Team,

I have created an app in here https://portal.azure.com/ and bot here https://dev.botframework.com/bots

I want to send a non reply message to a user using bot but it keeps showing an error like this

{
"error": {
"code": "AuthorizationError",
"message": "Invalid JWT."
}
}

I'm pretty sure that I use the right bearer token for the authentication because I have successfully started a conversation between bot and user, and got the conversation_id

239369-untitled.png

Here is my request for send a (non-reply) message [id will be blurred]

Method: POST
URL: https://smba.trafficmanager.net/apis/v3/conversations/{conversation_id}/activities
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json

Body

{
"type": "message",
"from": {
"id": "{bot_id}",
"name": "{bot_name}"
},
"conversation": {
"id": "{conversation_id}",
"name": "{conversation_name}"
},
"recipient": {
"id": "{receipient_id}",
"name": "{receipient_name}",
"aadObjectId": "{user_id}"
},
"text": "My bot's reply"
}

But then, I keep getting this error

Document referred:
https://learn.microsoft.com/en-us/previous-versions/azure/bot-service/rest-api/bot-framework-rest-connector-send-and-receive-messages?view=azure-bot-service-3.0#send-message

Thank you for your help

239326-image.png

Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
Azure Communication Services
Microsoft Partner Center API
{count} vote

Your answer

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