Copied to clipboard

Flag this post as spam?

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


  • Lee 1130 posts 3088 karma points
    Jan 25, 2014 @ 10:05
    Lee
    0

    404 For PluginController?

    I have the following plugin controller

    namespace Umbraco.Logic.Controllers.PluginControllers
    {
        [PluginController("Apt")]
        public class PartialPickerApiController : UmbracoAuthorizedJsonController
        {
            public IEnumerable<PartialPicker> GetFiles(string folder)
            {
                var list = new List<PartialPicker>();
                if (!string.IsNullOrEmpty(folder))
                {
                    var files = Directory.GetFiles(HostingEnvironment.MapPath(folder), "*.cshtml");
                    list.AddRange(files.Select(file => new PartialPicker {File = file}));
                }
                return list;
            } 
        }
    }
    

    And in my Factory/resource I call it like so

    angular.module('umbraco.resources').factory('partialpickerResource',
        function ($q, $http) {
            //the factory object returned
            return {
                //this cals the Api Controller we setup earlier
                getAll: function (folder) {
                    return $http.get("Apt/PartialPickerApi/GetFiles", {
                        params: { folder: folder }
                    });
                }
            };
        }
    );
    

    But I keep getting a 404 for the Url

    Request error: The URL returned a 404 (not found): 
    Apt/PartialPickerApi/GetFiles
    

    I've followed the tutorials and looked at other peoples propertyeditors and I can't see what I am doing differently? I'm using v7.0.2?

  • lucuma 261 posts 563 karma points
    Jan 25, 2014 @ 18:47
    lucuma
    0

    I suspect there is a path issue. See if /umbraco/Apt/PartialPickerApi/GetFiles works.

  • Lee 1130 posts 3088 karma points
    Jan 25, 2014 @ 19:09
    Lee
    0

    Thanks Lucuma - Found the issue. There is a break change in 7.0.2 and the url's change for backoffice urls

    http://umbraco.com/follow-us/blog-archive/2014/1/17/heads-up,-breaking-change-coming-in-702-and-62.aspx

  • SC Digital Services Team 104 posts 171 karma points
    Jan 30, 2014 @ 18:06
    SC Digital Services Team
    0

    Following on from this - where do you put the [IsBackOffice] attribute on the controller?

  • Frederik Østerbye 11 posts 81 karma points
    Jan 31, 2014 @ 08:14
    Frederik Østerbye
    0

    By inheriting from UmbracoAuthorizedJsonController the [IsBackOffice] attribute should be set, according to the article:

    "The good news is that this attribute is inherited, so we’ve decorated the UmbracoAuthorizedApiController with the [IsBackOffice] attribute which means that you will most likely not have to change any of your controller code because if you are using an UmbracoApiController in the back-office, 99% of the time you will be inheriting from UmbracoAuthorizedApiController. "

    The UmbracoAuthorizedJsonController inherits from UmbracoAuthorizedApiController, which should mean that you are home safe.


    I'm having the same problem, but the path pattern specified above doesn't work for me: "/umbraco/Races/DistanceApi/GetById"

    Application: "Races", Controller-name "DistanceApiController", Method: "GetById".

    I have also tried to insert til "Backoffice": "/umbraco/BackOffice/Races/DistanceApi/GetById"

  • SC Digital Services Team 104 posts 171 karma points
    Jan 31, 2014 @ 10:50
    SC Digital Services Team
    0

    Thanks Frederik - must have missed that paragraph!

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Jan 31, 2014 @ 14:16
    David Brendel
    1

    The path should be look like this in your resource:

    getall: function () {
        return $http.get("backoffice/EventCalendar/CalendarApi/GetAll");
    }
    
  • Frederik Østerbye 11 posts 81 karma points
    Jan 31, 2014 @ 14:46
    Frederik Østerbye
    0

    Hi David

    I've tried the path pattern but still get a 404-error. Have you tried this pattern?

    The pattern translate into the following get-request URL:

    http://localhost:16810/umbraco/backoffice/Races/DistanceApi/GetById?id=3

    I cannot wrap my head around what I'm doing wrong :-(

     

    - Frederik

  • Sergey Sagan 5 posts 25 karma points
    Mar 24, 2014 @ 05:29
  • Vishal Nakey 2 posts 72 karma points
    Sep 11, 2015 @ 14:47
    Vishal Nakey
    0

    From: http://umbraco.com/follow-us/blog-archive/2014/1/17/heads-up,-breaking-change-coming-in-702-and-62.aspx

    Chester Campbell Says: 17 Feb 14 @ 05:16 GMT+1

    I installed the UKFest Angular JS demo (found at https://github.com/Shandem/UkFest-AngularJS-Demo) into a bare Umbraco 7.0.3 site. As per this breaking change in 7.0.2 the routes to the PersonApi controller were returning 404 errors.

    Per this blog post I updated the api routes listed in person.resource.js like this:

    from ... People/PersonApi/GetById?id=

    to ... backoffice/api/People/PersonApi/GetById?id=

    I still get 404 responses.

    If I change the route to:

    backoffice/People/PersonApi/GetById?id=

    ... then it works correctly. So, given the back and forth between Kevin and Per I'm confused as to how these routes should be constructed. Is it with "/api/" or not?

  • Jonathan Roberts 409 posts 1063 karma points
    May 23, 2018 @ 09:38
    Jonathan Roberts
    0

    Out of curiosity is the PersonApi class public?

Please Sign in or register to post replies

Write your reply to:

Draft