0

I'm having a really simple issue that I cannot figure out how to word in search results so I'm hoping I can find the solution here by explaining.

I'm exploring the Helppage area in ASP.NET WebAPI. Currently I have a new endpoint set that accepts:

GET api/status/{id}

However when I look at the WebAPI auto generated Helparea documentation it shows this:

GET api/status/?id={id}

Can you either point me in the right direction to a good resource that explains how to format my xml comments correctly, or explain what I need to do to get the Helparea documentation to generate correctly.

I'm relatively new to ASP.NET so please let me know if I need to clarify anything regarding this and I'll be glad to.

Thanks for all the help and suggestions in advance.

This is where the endpoint is created

    /// GET: api/status/{id}
    /// <summary>
    /// Summary of my endpoint
    /// </summary>
    /// 
    /// <param name="id">summary of the param</param>
    /// <returns>What it returns</returns>
    [AllowAnonymous]
    public IHttpActionResult GetStatus(string id)
    {
    //  Doing stuff here
        return Ok();
    }

This is my WebApiConfig.cs

    namespace TestAPI
    {
        public static class WebApiConfig
        {
            public static void Register(HttpConfiguration config)
            {
                // Web API configuration and services
                // Configure Web API to use only bearer token authentication.
                config.SuppressDefaultHostAuthentication();
                config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

                // Web API routes
                config.MapHttpAttributeRoutes();

                config.Routes.MapHttpRoute(
                    name: "DefaultApi",
                    routeTemplate: "api/{controller}/{id}",
                    defaults: new { id = RouteParameter.Optional }
                );
            }
        }
    }
4
  • Can you paste your end point method declaration and any attributes on that end point? Commented Dec 7, 2016 at 14:47
  • I updated my post. Thanks Commented Dec 7, 2016 at 14:52
  • Can I see your WebApiConfig ? Commented Dec 7, 2016 at 14:55
  • I updated it again. Also I believe this is the default config that comes with the project template. Thanks - Just to clarify the end point works fine GET api/status/{id} Its the documentation that the Helparea generates that is the issue. Commented Dec 7, 2016 at 15:02

1 Answer 1

1

I've achieved exactly this using this configuration and endpoint:

TestController.cs

[RoutePrefix("api/test/v1")]
public class TestController : ApiController
{
    [HttpGet]
    public IHttpActionResult GetStuff(string id)
    {

        return Ok();
    }
}

WebApiConfig.cs

public static void Register(HttpConfiguration config)
{
    // Web API routes
    config.MapHttpAttributeRoutes();

    config.Routes.MapHttpRoute(
                    name: "defaultApiRoutes",
                    routeTemplate: "api/{controller}/{id}",
                    defaults: new { id = RouteParameter.Optional }
                );

}

And here's what it looks like on the help page :

enter image description here

Sign up to request clarification or add additional context in comments.

5 Comments

Thank you. I'm not sure why mine wasn't working, but it is now. What if I wanted to do something like this: GET api/order/{orderNumber} When I change id to something else it goes back to the old formatting.
Can you post another question regarding how to formulate end point parameters? I have a solution for it but it should be another question so others can benefit from it
Yes and no. It says I can only post every 90 minutes so I may have to revisit this later
Okay. Unfortunately I just got into a meeting. By the time I get out I should be able to answer. Sorry I just don't want to tuck away answers in comments! Appreciate your patience
Let me know if you still need an answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.