Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Alan Josephson 4 posts 24 karma points
    Dec 09, 2013 @ 04:48
    Alan Josephson
    0

    Trying to understand UmbracoApiController in standalone MVC 4 Web API project

    I am a newbie so please pardon me if this question has been asked and answered elsewhere (I cannot find it at any rate).

    I am trying to create a standalone MVC 4 Web API application that I can use to create services that query an Umbraco DB.

    I have:

     

    1. Created an MVC 4 Web API Project
    2. Added the Umbraco bin files (through nuGet) to the project
    3. Created a controller class (DocumentApiController) derived from UmbracoApiController)
    4. Copied the web.config file from a working Umbraco instance into the project
    When I try to access the controller (through http://localhost:2460/Umbraco/api/DocumentApi, per the documentation), I get a 404 saying resource cannot be found.
    When I try to access the controller (through http://localhost:2460/api/DocumentApi), I get:

     

    <Error>
    <Message>An error has occurred.</Message>
    <ExceptionMessage>
    Value cannot be null. Parameter name: umbracoContext
    </ExceptionMessage>
    <ExceptionType>System.ArgumentNullException</ExceptionType>
    <StackTrace>
    at Umbraco.Web.WebApi.UmbracoApiController..ctor(UmbracoContext umbracoContext) at Umbraco.Web.WebApi.UmbracoApiController..ctor() at JPMC.HR.Umbraco.POC.Controllers.DocumentApiController..ctor() at lambda_method(Closure ) at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)
    </StackTrace>
    </Error>
    Is there an initialization step I am missing for Umbraco in this scenario?  Do I need to remove the routings provided by the initial MVC 4 application?  Is what I am attempting to do even possible?
    Regards,
    Alan Josephson
  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Dec 09, 2013 @ 12:08
    Jeroen Breuer
    0

    Hello,

    The Umbraco WebAPI only works if it's used on an Umbraco website. If you want a standonline MVC web app that uses the Umbraco API you could have the WebAPI on your Umbraco project do the work with the Umbraco API and connect to that WebAPI in your own project.

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft