locked
problem with my first web api call RRS feed

  • Question

  • User-1556678718 posted

    Hi I have web api application with Visual Studio 2017.  I have set the bin folder  to be a new application in IIS with some name like aaa.  In the web api I have  controller with  name bbbController. The code from the controller:

    namespace MyApi.Controllers
    {
        public class bbbController : ApiController
        {
            [HttpPost]
            public MyResponseMessage Login123(MyRequest request)
            {
                MyResponseMessage msg = new MyResponseMessage();
               
                return msg;
            }
        }
    }
    

    and in  WebApiConfig I have 

    using System.Web.Http;
    
    namespace MyApi
    {
        public static class WebApiConfig
        {
            public static void Register(HttpConfiguration config)
            {
                // Web API configuration and services
    
                // Web API routes
                config.MapHttpAttributeRoutes();
    
                config.Routes.MapHttpRoute(
                    name: "DefaultApi",
                    routeTemplate: "api/{controller}/{id}",
                    defaults: new { id = RouteParameter.Optional }
                );
            }
        }
    }
    

    When I try to get with postman POST http://localhost/aaa/api/bbb or POST http://localhost/aaa/api/bbbController I'm getting response 404 Not found. How can I get my api call? Is there a way to see a list of all api calls for some web site or web api application? Please advice

    Tuesday, July 18, 2017 8:01 AM

Answers

  • User1168443798 posted

    Hi RioDD,

    >> I have set the bin folder  to be a new application in IIS with some name like aaa.

    You need to set the project folder instead of bin folder.

    I suggest you follow below steps:

    Open IIS->Select your web application(aaa)->Basic Settings->Physical path to project folder(remove /bin)->restart application-> access your web api by http://localhost/aaa/api/bbb

    Best Regards,

    Edward

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 19, 2017 3:04 AM

All replies

  • User-718411499 posted

    Please make sure you have all the configuration registered and are in the right order

    AreaRegistration.RegisterAllAreas();
    WebApiConfig.Register(GlobalConfiguration.Configuration);
    FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
    RouteConfig.RegisterRoutes(RouteTable.Routes);
    **********Please mark this reply as answer if that works for you**************

    Tuesday, July 18, 2017 7:26 PM
  • User1120430333 posted

    How can I get my api call? Is there a way to see a list of all api calls for some web site or web api application? Please advice

    http://www.asjava.com/tools/fiddler-tutorial-how-to-use-fiddler/

    Tuesday, July 18, 2017 8:35 PM
  • User1168443798 posted

    Hi RioDD,

    >> I have set the bin folder  to be a new application in IIS with some name like aaa.

    You need to set the project folder instead of bin folder.

    I suggest you follow below steps:

    Open IIS->Select your web application(aaa)->Basic Settings->Physical path to project folder(remove /bin)->restart application-> access your web api by http://localhost/aaa/api/bbb

    Best Regards,

    Edward

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 19, 2017 3:04 AM