Hello,
We are encountering an issue with multiple POST requests being sent to our API.
We created an outgoing webhook in our team, and when we mention this webhook (e.g., @Teams Test 1 test message), it triggers 3 or more identical messages to our API.
Please see the example below:
We tested it using the Node.js example from this repository: Microsoft Teams Samples - Outgoing Webhook (Node.js). This example is suggested by the following article: Add an outgoing webhook.
Additionally, we tested it using a simple Ruby Grape API and encountered the same issue. The Teams outgoing webhook is being sent to our API multiple times.
class API::V1::IncomingWebhooks::Messages < Grape::API
format :json
helpers do
def request_hmac_signature
request.headers['authorization'].to_s.split[1]
end
def valid_hmac?
serialized_payload_bytes = request.body.read.encode('utf-8')
key_bytes = Base64.decode64(ENV['TEAMS_SECRET'])
hmac_sha256 = OpenSSL::HMAC.digest('sha256', key_bytes, serialized_payload_bytes)
calculated_hmac_value = Base64.encode64(hmac_sha256).strip
request_hmac_signature == calculated_hmac_value
end
end
namespace 'incoming_webhooks/:id' do
resources :messages do
desc 'Creates message'
post do
return unauthorized! unless valid_hmac?
{ type: 'message', text: 'Successfully received' }
end
end
end
end
The result is the same
Is there any solution to fix it?
Thanks!