I'm attempting to send a message from an Azure Function to an Azure SignalR Service and its returning a 415 but I'm unsure on how to identify the cause of the issue.
I already have a working implementation for the front end of the application with users and actions able to broadcast messages through the SignalR Service however I now need a backend function to notify the users when it has completed.
The example I've followed is the one here; https://github.com/Microsoft/MTC_WhackAMole.NET/blob/master/MoleDeploy.SignalR/AzureSignalR.cs
When executing the function, it successfully completes the SendAsync() function but doesn't actually trigger anything.
var payload = new PayloadMessage()
{
Target = methodName,
Arguments = args
};
var url = $"{endpoint}/api/v1/hubs/{hubName}";
var bearer = GenerateJwtBearer(null, url, null, DateTime.UtcNow.AddMinutes(30), accessKey);
await PostJsonAsync(url, payload, bearer);
It's only when trying the same request in Postman that I get the 415 error.
In Postman, I'm posting to the following url;
https://xxxxxx.service.signalr.net/api/v1/hubs/{hubName}
Using a bearer authentication token (that I know is correct as changing it generates a 401 as apposed to the 415)
Its sending the following payload;
{"Target":"hubFunctionName","Arguments":"message to broadcast"}
What I'm not entirely sure on is the posted body. Should the Target be the function in the hub and the Arguments be the message to send?
Looking at the payload that is sent in PostJsonAsync() it comes out as;
payload {AzureFunctionName.AzureSignalR.PayloadMessage}
--Arguments {object[1]}
----[0] "message to broadcast"
--Target "hubFunctionName"
The function in the hub is super basic;
public void Send(string messageText)
{
Clients.All.broadcastMessage(messageText);
}
If anyone could point me in the right direction with this it would be greatly appreciated.
Thanks, Tom