0
votes

I'm using sendgrid WebHook, i already enabled Event Notification Here:

https://app.sendgrid.com/settings/mail_settings

SendGridMailSettings

When i Click Test Your Configuration, its works and sends me a POST to my configured URL, but i don't get any data from the POST with the default parameters they explain in the documentation Here:

https://sendgrid.com/docs/API_Reference/Webhooks/event.html

When i try to send data from my computer to the server it does register the data i input on the URL...

Here is my code:

    <%@ WebHandler Language="VB" Class="HandlerSendGrid" %>

Imports System
Imports System.Web

Public Class HandlerSendGrid : Implements IHttpHandler

    Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

        Dim sgevent As String = If(IsNothing(context.Request.QueryString("event")), "naopossui", context.Request.QueryString("event"))
        Dim email As String = If(IsNothing(context.Request.QueryString("email")), "naopossui", context.Request.QueryString("email"))
        Dim response As String = If(IsNothing(context.Request.QueryString("response")), "naopossui", context.Request.QueryString("response"))
        Dim sgid As String = If(IsNothing(context.Request.QueryString("sg_event_id")), "naopossui", context.Request.QueryString("sg_event_id"))
        Dim bounce As String = If(IsNothing(context.Request.QueryString("bounce")), "naopossui", context.Request.QueryString("bounce"))
        Dim click As String = If(IsNothing(context.Request.QueryString("click")), "naopossui", context.Request.QueryString("click"))
        Dim open As String = If(IsNothing(context.Request.QueryString("open")), "naopossui", context.Request.QueryString("open"))

        Dim ID As Integer = EmailDL.InsSGTeste(sgevent, email, response, sgid, bounce, click, open)
    End Sub

    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
        Get
            Return False
        End Get
    End Property

End Class

What i am doing is getting the data that's past on the URL and then Inserting into my DB all the parameters i receive, if there's no data in those parameters the parameters will only be a string named "naopossui".

1

1 Answers

0
votes

Already solved this by doing exactly how this is in c# converting into vb

https://sendgrid.com/blog/tracking-email-using-azure-sendgrid-event-webhook-part-1/