4

This is for those who have tried using Mandrill .NET in github.

I need to be able to process inbound mails, and based on Mandrill documentation, I have to create a webhook with a corresponding public url. In terms of implementing the action method, I followed the method signature as described in the documentation of WebHookEvent.cs. At that point everything was working as expected: if I send mail to the mandrill email which I registered to the webhook event, the action method is invoked from Mandrill. For discussions's sake let's assume that the method name is ProcessInboundMail.

Moving forward, my app needs to support multitenancy. So instead of a straightforward processing in the method ProcessInboundMail, I have to somehow Redirect to a url that includes the appropriate subdomain (e.g. company1.myapp.com/mycontroller/ProcessInboundMail). From then on I started to encounter a peculiar issue.

If I send mail to the mandrill email, the action method is no longer properly executed. To verify if the webhook is working, I went to the mandrill admin page > Inbound > Domains (InboundDomains.png), clicked Routes button, then clicked the button "send test" (MailboxRoutes.png), but all I get is this error message: Webhook failed with error: POST to http://myapp.com/mycontroller/ProcessInboundMail failed with 411: Length Required Length Required HTTP Error 411. The request must be chunked or have a content length.

Here is how my ProcessInboundMail looks like:

    [AllowAnonymous]
    [ValidateInput(false)] // May be required if accepting inbound webhooks
    [AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post | HttpVerbs.Head)]
    public ActionResult ProcessInboundMail(string id, FormCollection val)
    {
        var events = Mandrill.JSON.Parse<List<Mandrill.WebHookEvent>>(val.Get("mandrill_events"));
        foreach (var e in events)
        {
    //logic here...
            var redirectResult = Redirect(toSomeUrl);
            redirectResult.ExecuteResult(this.ControllerContext);   
         }
        return Json(1, JsonRequestBehavior.AllowGet);
    }

My question is, how come when I was not using Redirect, clicking "send test" was successful, but now that I am using Redirect, I'm getting this HTTP error 411 when clicking "send test"? What am I doing wrong here?

0 Answers0