WebPush {"Unexpected response code received"}
How to send a notification using the Webpush library. I tried but it gives a msg error like{"Received unexpected response code"}
**** Now I have created a web API to send notifications and call you via fiddler, but did not get an exception, it got stuck somewhere here is my example code ****
public void Sendnotification()
{
try
{
WebPush.VapidDetails vapidKeys = apidHelper.GenerateVapidKeys();
string subject =@"mailto:xyz.com";
string publicKey = Convert.ToString(vapidKeys.PublicKey);
string privateKey = Convert.ToString(vapidKeys.PrivateKey);
var subscription = new PushSubscription(pushEndpoint, p256dh, auth);
var vapidDetails = new VapidDetails(subject, publicKey, privateKey);
client.SendNotification(subscription, "payload", vapidDetails);
}
catch (WebPushException e)
{
}
}
I have configured Https to call an api using fidder. Please look. also his mistake, she got stuck somewhere
now it got an error please see it shows HTTP / 1.1 410 NotRegistered error
source to share
If you get error 410 (to test using fiddler error to intercept https call), it is possible that you have an error in the user's subscription data, perhaps the keys stored in your database do not match the subscription in the browser, an easy fix could be to re-subscribe and re-save the subscription data and try again.
to set up fiddler you must use it as a proxy visual studio to intercept https calls and also you must enable https decryption.
EDIT
you can customize the script by adding this config to your web.config or app.config file:
<system.net>
<defaultProxy
enabled = "true"
useDefaultCredentials = "true">
<proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:8888" usesystemdefault="false" />
</defaultProxy>
</system.net>
If you receive an unauthorized registration anyway, check the following questions:
source to share