Page 1 of 1

Rest API

Posted: Mon May 13, 2013 10:56 pm
by jpodz
Hey All,
I'm having trouble getting the Broadleaf REST API to work. I've followed the steps involved in: http://docs.broadleafcommerce.org/2.2/R ... rials.html, but every endpoint that I hit gives a IllegalArgumentException.

Here's my web.xml:

Code: Select all

...
<servlet>
    <servlet-name>JerseyServlet</servlet-name>
    <servlet-class>
        com.sun.jersey.spi.spring.container.servlet.SpringServlet
    </servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>JerseyServlet</servlet-name>
    <url-pattern>/commerce/*</url-pattern>
</servlet-mapping>
...


And here's my applicationContext.xml:

Code: Select all

...
<context:component-scan base-package="org.broadleafcommerce.core.web.api"/>
...


Here's the url that I've been trying:

http://localhost:8080/api/commerce/cata ... hot-sauces

On a related note, I couldn't quite figure out which dependencies to add to my pom.xml, so I added all that were provided with the DemoSite. Can anyone please shed some light on what the issue could be? Or possibly where to look to determine why these endpoints aren't being hit?

Re: Rest API

Posted: Tue May 14, 2013 11:05 am
by phillipuniverse
It doesn't look like that is a valid endpoint at all. What you are probably looking for is the findProductsForCategory method in CatalogEndpoint. This is annotated with:

Code: Select all


    
@Override
    
@GET
    
@Path("category/{id}/products")
    public List<
ProductWrapperfindProductsForCategory(@Context HttpServletRequest request,
 


So you would have to instead hit: http://localhost:8080/api/commerce/catalog/category/<hot-sauces-category-id>/products