skip to Main Content

I need to configure a route such as https://example.com./api/NotesApi/WebHook/pix, to receive a HTTP POST request from a third party API. My site is ASP.NET Webforms running on .NET 4.6.1. Global.asax looks like this, under app_start:

RouteTable.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{action}/{id}", New With {Key .id = System.Web.Http.RouteParameter.[Optional]) 

And then in the NotesApiController.vb I have

Public Sub WebHook(ByVal request As HttpRequestMessage)
    Dim json = request.Content.ReadAsStringAsync().Result
    ...
End Sub

I tested that I can trigger this method by sending a post to

https://example.com./api/NotesApi/WebHook

but the API sends the request to

https://example.com./api/NotesApi/WebHook/pix

and I have no idea how to configure this /pix part in the controller. Appreciate any help

2

Answers


  1. Chosen as BEST ANSWER

    Ok, so I finally got it working by applying the good ole Trial 'n Error method:

             <HttpPost()>
        Public Function WebHook(pix As JObject) As HttpStatusCode
    

  2. You can try this:

    RouteTable.Routes.MapHttpRoute("DefaultApi", 
                                   "api/{controller}/{action}/{id}/pix", 
                                   New With {Key .id = System.Web.Http.RouteParameter.[Optional]) 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search