User-1330468790 posted
Hi kengkit,
Basically, your codes are correct and should be working provided you have configured the WebApiConfig.cs correctly firstly. In another word, the problem might locate in Route Configuration.
I can see that in the previous version of your description is that you have used the route "https://mydomain.com/api/registration/GetData". This requires you configure a route to map "api/{controller}/{action}".
However, the default route is "api/{controller}/{id}" which does not contain the route parameter "{action}".
You might need to add a route as below to reach the action:
config.Routes.MapHttpRoute(name:="ActionApi", routeTemplate:="api/{controller}/{action}/{id}", defaults:=New With {Key
.id = RouteParameter.[Optional]
})
Moreover, the action should be set as following format (below is just a simple example so that you have to write your own action to fit your scenario):
<HttpPost>
Public Function GetData(
<FromBody> ByVal user As User) As String
Dim user1 As User = user
Return JsonConvert.SerializeObject(user1)
End Function
Public Class User
Public Property APIKey As String
Public Property FullName As String
Public Property Username As String
Public Property Password As String
End Class
Hope this can help you.
Best regards,
Sean