Invalid request Check "Errors" for a list of errors returned by the API. in SendGrid

I use the send grid to send emails after the user is created, and I follow this guide. http://www.asp.net/identity/overview/features-api/account-confirmation-and-password-recovery-with-aspnet-identity I even downloaded this tutorial and wrote the code since it

but it breaks into this

string code = manager.GenerateEmailConfirmationToken(uApp.Id);
string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, uApp.Id, Request);
 manager.SendEmail(uApp.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>.");

Its this third how

manager.SendEmail(uApp.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>.");

Where does the code break

and errors are like these

Exceptions .InvalidApiRequestException: checking for invalid request Errors , API. SendGrid.Web.d__c.MoveNext() - , - System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task ) System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task ) System.Runtime.CompilerServices.TaskAwaiter.GetResult() at SendGrid.Web.d__0.MoveNext() --- , - System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task ) System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task ) System.Runtime.CompilerServices.TaskAwaiter.GetResult() at GCRweb.EmailService.d__0.MoveNext()

bla bla bla , -

+4
3

, , , , .

public static bool ForgotPassword(string fromAccount, string toAccount, string subject, string msg)
    {
        var ConfirmationMail = new MailMessage();
        if (IsLiveMode)
        {
            ConfirmationMail = new MailMessage("abc@abc.com", toAccount, subject, msg);
        }
        else
        {
            ConfirmationMail = new MailMessage("abc@abc.com", toAccount, subject, msg);
                       }
         ConfirmationMail.Priority = MailPriority.High;
        ConfirmationMail.IsBodyHtml = true;
        SmtpClient objSMTPClient = new SmtpClient();
        try
        {
            objSMTPClient.Send(ConfirmationMail);
            return true;
        }
        catch
        {
            return false;
        }
    }

<system.net>
<mailSettings>    
  <smtp from="no-reply@no-reply.com">
    <network host="smtp.live.com" password="abcdefghijk" port="587" userName="atteeqKhawaja@msn.com" enableSsl="true" />
  </smtp>     
</mailSettings>

string code = manager.GeneratePasswordResetToken(user.Id);
            string callbackUrl = IdentityHelper.GetResetPasswordRedirectUrl(code, Request);

            bool emailSent = ForgotPassword(" khawaja Atteeq", Email.Text, "Reset Password", "Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>.");
+3

InvalidApiRequestException .

DeliverAsync() - :

            try
            {
                await transportWeb.DeliverAsync(mensaje);
            }
            catch (InvalidApiRequestException ex)
            {
                var detalle = new StringBuilder();

                detalle.Append("ResponseStatusCode: " + ex.ResponseStatusCode + ".   ");
                for (int i = 0; i < ex.Errors.Count(); i++)
                {
                    detalle.Append(" -- Error #" + i.ToString() + " : " + ex.Errors[i]);
                }

                throw new ApplicationException(detalle.ToString(), ex);
            }
+6

I had the same problem, check Web.config. The original tutorial says that value = "[Sendgridname]", after deleting [] it should work fine. See below.

<appSettings>
    <add key="emailServiceUserName" value="SendGridUserName" />
    <add key="emailServicePassword" value="SendGridPassword" />
  </appSettings>
+2
source

All Articles