I am trying to get an API help page to show all the API endpoints, and show them in the style I want.
Here are my routes:
config.Routes.MapHttpRoute("Orgs", "v1/Orgs/{orgId}", new { controller = "Orgs", orgId = RouteParameter.Optional }); config.Routes.MapHttpRoute("OrgDescendants", "v1/Orgs/{orgId}/Descendants", new { controller = "Orgs", action = "OrgDescendants" });
Here are all my management methods:
[HttpGet] public IEnumerable<Org> GetAllOrgs() [HttpGet] public Org Get(string orgId) [HttpGet] [ActionName("OrgDescendants")] public List<Org> Descendants(string orgId) [HttpPost] public HttpResponseMessage Post(Org org) [HttpPut] public HttpResponseMessage Put(string orgId, Org org) [HttpDelete] public void Delete(string orgId)
And here are the endpoints displayed on the help page:
GET v1/Orgs POST v1/Orgs PUT v1/Orgs/{orgId} DELETE v1/Orgs/{orgId} GET v1/Orgs/{orgId}/Descendants
As you can see, the following endpoint is missing from the help page:
GET v1/Orgs/{orgId}
I tried so many different routing permutations that I lost. No matter what I try, I always end up with the absence of some endpoints or the "wrong" formatting.
For example, I get:
GET v1/Orgs/{orgId}/Get
when I want:
GET v1/Orgs/{orgId}
or I get:
PUT v1/Orgs?orgId={orgId}
when I want:
PUT v1/Orgs/{orgId}
No matter what combination I try, I cannot get them the way I want them. Any help would be greatly appreciated!
source share