Reputation: 21
"message": "No HTTP resource was found that matches the request URI 'http://localhost:64221/api/companies/lncr/Orders/00029303_070/Lines/6'.",
"messageDetail": "No action was found on the controller 'PurchLines' that matches the request."
[RoutePrefix("api/companies/{compId}/Orders/{orderId}/Lines")]
public class PurchLinesController : BaseApiController
{
public PurchLinesController(IPortalReposotry repo)
: base(repo)
{
}
[Route("")]
public HttpResponseMessage Get(String compId, String orderId, int levelOfDetails = 1)
{
IQueryable<PurchLine> query;
if (levelOfDetails == 1)
{
query = PortalReposotry.GetPurchasLines(compId, orderId);
}
else
{
query = PortalReposotry.GetPurchasLinesWithApprovalHist(compId, orderId);
}
if (query.Count() == 0)
{
return Request.CreateResponse(HttpStatusCode.NotFound);
}
var results = query.ToList()
.Select(v => this.ModelFactory.Create(v));
return Request.CreateResponse(HttpStatusCode.OK, results);
}
[Route("{lineId:double}" , Name="line")]
public HttpResponseMessage Get(String compId, String purchId, double lineId, int levelOfDetails = 1)
{
PurchLine results;
if (levelOfDetails == 1)
{
results = PortalReposotry.GetPurchasLine(compId, purchId, lineId);
}
else
{
results = PortalReposotry.GetPurchasLineWithApprovalHist(compId, purchId, lineId);
}
if (results == null)
{
return Request.CreateResponse(HttpStatusCode.NotFound);
}
return Request.CreateResponse(HttpStatusCode.OK, ModelFactory.Create(results));
}
}
The request should be matching the second Get request.
api/companies/{compId}/Orders/{orderId}/Lines/{lineId}
http://localhost:64221/api/companies/lncr/Orders/00029303_070/Lines/6
The lineId is a type of double, I have also tried http://localhost:64221/api/companies/lncr/Orders/00029303_070/Lines/6.0/
But that didn't work either so I am sort of at a loss here to what I am doing wrong.
Upvotes: 0
Views: 33
Reputation: 21
I found my error, the second get response had the purchId but my RoutePrefix was defined as orderId. easy oversight.
Upvotes: 0