I am following this tutorial https://learn.microsoft.com/en-us/azure/communication-services/tutorials/postman-tutorial
Using this same code, I called https://learn.microsoft.com/en-us/rest/api/communication/callautomation/create-call/create-call?view=rest-communication-callautomation-2023-10-15&tabs=HTTP and it works perfectly.
Next step, I called https://learn.microsoft.com/en-us/rest/api/communication/callautomation/call-media/play?view=rest-communication-callautomation-2023-10-15&tabs=HTTP with the callConnectionId I obtained from the previous API call.. and I keep getting
{
"error": {
"code": "7509",
"message": "HMAC-SHA256 validation failed"
}
}
My body for CallMedia-> play is
{
"playSources": [
{
"kind": "text",
"text": {"voiceKind": "male", "text": "Hello. This is Microsoft calling. If you are trying to authenticate, please press the pound or hash key now", "sourceLocale" : "en-US"}
}
],
"playTo": [
{
"phoneNumber": {
"value": "+11231230672"
}
}
]
}
Where am I going wrong?
I tried changing
pm.request.headers.upsert({
key:'Authorization',
value: "HMAC-SHA256 SignedHeaders=date;host;x-ms-content-sha256&Signature=" + signature
});
to
pm.request.headers.upsert({ key:'Authorization', value: "HMAC-SHA256 Credential=" + pm.variables.get("credential") + "&SignedHeaders=x-ms-date;host;x-ms-content-sha256&Signature=" + signature });
But that leads to an "invalid header parameter"
I tried hardcoding endpoint, url .. but no luck.
Can you please help?
2
Answers
The final solution was this
Postman pre-request script
Call request post-response script
Call request body
Recognize API call
Has headers added for Ocp-Apim-Subscription-Key = User-Agent : Something Voice OTP
Body
RETRY Recognize API call
Has headers added for Ocp-Apim-Subscription-Key = User-Agent : some Voice OTP
Body
DECLINE auth API call
Has headers added for Ocp-Apim-Subscription-Key = User-Agent : Some Voice OTP
Body
Terminate auth API call
Has headers added for Ocp-Apim-Subscription-Key = User-Agent : BHPS Voice OTP
Body
None
The issue with HMAC-SHA256 validation when trying to make a call to the Azure Communication Services (ACS) API for playing media during a call due to invalid key details.
The following are steps to CallMedia play:
Connect the Cognitive Services to the Communication Service
Add collection variables for Call Setup and create two variables:
key – This variable should be one of your keys from your Azure Communication Services’ key page within the Azure portal. For example,
oW...A==
.endpoint – This variable should be your Azure Communication Services’ endpoint from the key page. Ensure you remove the trailing slash. For example,
https://contoso.communication.azure.com
.Call Setup with Cognitive Services:
Play Call with Text-to-Speech:
Output: