Trying to create web api url for getting web hook response when an event occurred in mail gun RRS feed

  • Question

  • User-1123897551 posted


    I created a web api URL and hosted in environment. And assign this web URL to web hook in mail gun

    find my code below

    // POST api/mailgun
    public HttpResponseMessage Post(HttpRequestMessage msg)
    var recipient = msg.Content;
    string jsonContent = recipient.ReadAsStringAsync().Result;
    return Request.CreateResponse(HttpStatusCode.OK, jsonString);

    I can not get reply from the above post method. 

    Thanks in advance

    Saturday, May 7, 2016 7:36 AM


  • User36583972 posted

    Hi pthummala,

    From your description, you can try the following method.

            // POST api/mailgun
            public HttpResponseMessage Post(HttpRequestMessage msg)
                string jsonContent = msg.Content.ReadAsStringAsync().Result;
                if (jsonContent != "")
                    SuccessResponse success = new SuccessResponse();
                    success.success = jsonContent;
                    return Request.CreateResponse(HttpStatusCode.OK, success);
                    ErrorResponse errors = new ErrorResponse();
                    errors.error = "no message!";
                    errors.success = "1";
                    return Request.CreateResponse(HttpStatusCode.OK, errors);

    Action Results in Web API 2:


    Best Regards,

    Yohann Lu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 9, 2016 4:57 AM