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?
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"
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?
404 For PluginController?
I have the following plugin controller
And in my Factory/resource I call it like so
But I keep getting a 404 for the Url
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?
I suspect there is a path issue. See if /umbraco/Apt/PartialPickerApi/GetFiles works.
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
Following on from this - where do you put the [IsBackOffice] attribute on the controller?
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"
Thanks Frederik - must have missed that paragraph!
The path should be look like this in your resource:
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
Mine ended up being:
http://localhost:62154/umbraco/backoffice/Apt/PartialPickerApi/GetFiles
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?
Out of curiosity is the PersonApi class public?
is working on a reply...