// #############################
// # DATA RESOURCES (Data API) #
// #############################
// Get Data
getData: function (id, itemsPerPage, pageNumber) {
return $http.get('MyPlugin/MyDataApi/GetData', { params: { id: id, itemsPerPage: itemsPerPage, pageNumber: pageNumber } });
},
// Get Filtered Data
filterData: function (id, search, itemsPerPage, pageNumber) {
return $http({
method: 'POST',
url: 'MyPlugin/MyDataApi/PostFilterData',
data: { id: id, search: search, itemsPerPage: itemsPerPage, pageNumber: pageNumber }
});
}
And my custom controller (dataAPIController.cs):
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web.Mvc;
using Umbraco.Core.Cache;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence;
using Umbraco.Web.Mvc;
using Umbraco.Web.WebApi;
namespace My.Controllers
{
[PluginController("MyPlugin")]
public class MyDataApiController : UmbracoApiController
{
[HttpGet]
public MyDataModel GetData(string id, int itemsPerPage = 10, int pageNumber = 1)
{
// my code
}
[HttpPost]
public MyDataModel PostFilterData(string id, string search, string itemsPerPage, string pageNumber)
{
// my code
}
}
}
The "GetData" action function properly, but with the "PostFilterData" action I receive this message:
Request error: The URL returned a 404 (not found):
MyPlugin/MyDataApi/PostFilterData
with data:
{"id":"1","search":"service","itemsPerPage":10,"pageNumber":"1"}
Contact your administrator for information.
Request error: The URL returned a 404 (not found)
Hi, I have a custom section with my custom tree and relative actions. In my view I have a table and a form to filter table results.
This is the form inside the view (myview.html):
This is the code to call the action to filter table data (mycontroller.js):
This is my resource file (myresource.js):
And my custom controller (dataAPIController.cs):
The "GetData" action function properly, but with the "PostFilterData" action I receive this message:
What am I doing wrong?
Thank you for the support
A.
The problem was on params...They were not correctly passed to the method.
Problem solved
Hi Adriano,
I think I am having a similar error. Do you remember how the params were passed incorrectly?
Thanks
Niall
Hi Niall, I recently change my code to improve performance and to have more flexibility.
You can find it in the source code of my FALM Housekeeping Package.
I used the filter form in "db log manager", "trace log manager" and "versions manager".
Hope this help you
Adriano
is working on a reply...