Replies: 1 comment 1 reply
-
No matter which framework you chose (MVC, ASPX, etc.) there are only two requirements to be able to parse webhook messages received from SendGrid using StrongGrid:
I included the following sample in the readme which I hope provides a good indication: namespace WebApplication1.Controllers
{
[Route("api/SendGridWebhooks")]
public class SendGridController : Controller
{
[HttpPost]
[Route("Events")]
public async Task<IActionResult> ReceiveEvents()
{
var parser = new WebhookParser();
var events = await parser.ParseWebhookEventsAsync(Request.Body).ConfigureAwait(false);
... do something with the events ...
return Ok();
}
}
}
It's hard for me to guess what might cause this error. Maybe you're not using the latest Web API???? Here is what I see in Visual Studio when I create a new web api. Do you see the same? The sample I provided works fine if you click on the option I highlight in the screenshot.
As I said, you can use any framework you prefer, you'll simply need to figure out the proper syntax to get the payload and the way to return the respond HTTP 200. |
Beta Was this translation helpful? Give feedback.
-
Hi Jericho,
I've just discovered your excellent codebase and was wondering what is the best way to implement this into a Web Service / API project?
What sort of project do you recommend? I've tried to create a new Web API 2.0 project but I'm new to MVC and am not sure how to get such a project to work.
I'm trying to parse a signed Webhook but have issues with the lines
The Request.Body shows an error HttpRequestBase does not contain a definition for 'Body' and Return Ok() says The name Ok does not exist in the current context. I've used the exact same code as in your example so am guessing that perhaps a Web API 2.0 project is not the way to go.
Is is possible to implement this code in an existing WebService we have that uses asmx and SOAP?
Do you have any sample projects I could use for reference or further documentation floating around the web somewhere that I might find useful in setting this up?
Apologies for my ignorance but as I say, I'm rather new to this.
Thanks for your time,
Stuart
Beta Was this translation helpful? Give feedback.
All reactions