alfredoi6
alfredoi6

Reputation: 3

How do I solve the WebAPI 404 error with the sample module code from Virtocommerce

I've going through the sample tutorial provided in the Virtocommerce documentation.

http://docs.virtocommerce.com/display/vc2devguide/Creating+new+module

I'm using the exact code from the following location provided in the documentation

http://docs.virtocommerce.com/download/attachments/13303913/ManagedModule.zip?version=6&modificationDate=1458663072657&api=v2

I have most of the code running but I keep getting a 404 error with the WebAPI sample for the module.

I have the Virtocommerce code running as an application under my default website on my local dev machine.

I feel like the issue is probably in my API controller. Here is my code

using System.Web.Http;

namespace VirtoCommerce.Module1.Web.Controllers.Api
{
    [RoutePrefix("api/module1")]
    public class Module1Controller : ApiController
    {
        // GET: api/module1/
        [HttpGet]
        public IHttpActionResult GetData()
        {
            return Ok(new[] { "Hello world!" });
        }
    }
}

What is a good way to debug this 404 error?

Upvotes: 0

Views: 93

Answers (1)

Dartal
Dartal

Reputation: 432

The GetData() method should also have the [Route("")] attribute:

[HttpGet]
[Route("")]
public IHttpActionResult GetData()
{
    return Ok(new[] { "Hello world!" });
}

Upvotes: 0

Related Questions