Failed to send test message. Error: {"error":{"code":"BadRequest","message":"WNS type is required (Parameter 'RequestHeaders')

sem 25 Reputation points


I'm moving on documentation

I went through all the steps and successfully won the console in my c# application

After a lot of tests i started to get an error

Failed to send test message. Error: {"error":{"code":"BadRequest","message":"WNS type is required (Parameter 'RequestHeaders').TrackingId:ef9597e6-1088-4f8d-9efc-17fc6fb12008,TimeStamp:3/1/2023 6:01:06 AM +00:00"}}.

Sending via azure web interface

Platform: windows

Send to Tag Expression: -

Notification Type: Toast


<?xml version="1.0" encoding="utf-8"?>


<visual><binding template="ToastText01">

<text id="1">Test message</text>




Azure Notification Hubs
Azure Notification Hubs
An Azure service that is used to send push notifications to all major platforms from the cloud or on-premises environments.
260 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Microlead Software 1 Reputation point

    I was facing same issue but finally make it work. i'm using Maui App but test it on Universal Windows App and it worked too.

    follow these steps, if your setup of the notification hub is successful, it may help:

    1- In the OnLaunched() add these lines:

            var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
            channel.PushNotificationReceived += Channel_PushNotificationReceived;
            NotificationHubClient hub = new NotificationHubClient("Endpoint=sb://DefaultListenSharedAccessSignature connection string", "YOURHUBNAME");
            var reg = await hub.CreateWindowsNativeRegistrationAsync(channel.Uri);

    make sure that the connection string is the listener connection string not the full access CS.

    optionally you can add tags to send to while registering the channel uri with CreateWindowsNativeRegistrationAsync(channelUri, new { array of tags })

    2- Add the Notification received handler:

    private void Channel_PushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args)
            //handle notification received here
                var data = args.ToastNotification.Data;

    3- Run the app, and test to send notification, without tags or to tags you already register them.

    for this to work you need to correctly sign your application by right click the project and "Publish...".

    The 403 code is caused by incorrect signature of your app or from invalid access token that you have to request to send push to a specific channel or tag. by using your Client Security Key (O~....) and the Package SID (ms-app://S-....)

    hope this help

    0 comments No comments