Hi 01DT We're glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer. Issue: -you attempted to make a phone call using Call Automation REST API with a service principal -you were able to get a bearer token using the Oauth client credentials and it passed to make the API call however you got a 400 "invalid request" error code Solution: -you were able to make a phone call by generating a new identity within your request body [https://learn.microsoft.com/en-us/rest/api/communication/communication-identity/create?tabs=HTTP ] which resolved your issue If you have any other questions or are running into more Azure Communication Service issues, please let us know. Thank you again for your time and patience throughout this issue. -Grace
How do I make a phone call using Call Automation REST API with a service principal?
Hello,
I want to make a phone call using the REST API endpoint here:
I am testing in Postman and I have a Service Principal that is granted access to the Azure Communication Services endpoint. I am able to get a bearer token using the Oauth client credentials flow and am able to pass it along to make the API call.
This is my request body:
{
"source": {
"identifier": {
"communicationUser": {
"id": "{{insertIdHere}}"
}
}
},
"targets": [
{
"kind": "phoneNumber",
"phoneNumber": {
"value": "+{{insertPhoneNumberHere}}"
}
}
],
"callbackUri": "{{mycallbackUriHere}}"
}
This is the response body:
{
"error": {
"code": "400",
"message": "Invalid request",
"details": [
{
"message": "Invalid Identifier in request, CommunicationUserIdentifier is required but provided CommunicationUserIdentifier is invalid.",
"target": "Source.Identifier"
}
]
}
}
I have an Azure phone number that I have tried to substitute under source.identifer but it yielded the same response as above.
Do I need to create a new identity via https://learn.microsoft.com/en-us/rest/api/communication/communication-identity/create?tabs=HTTP in order to make this API call work even with a service principal?