by JuiceyBrucey » Sat Mar 06, 2021 5:32 pm
Using the above as a template, I have tried to make a similar one, but am getting a 404 handler not found.
This is the code:
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using JiwaFinancials.Jiwa;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Drawing;
using ServiceStack;
using ServiceStack.DataAnnotations;
using ServiceStack.Model;
using JiwaFinancials.Jiwa.JiwaServiceModel.Tables;
using ServiceStack.Auth;
using System.Linq;
using ServiceStack.OrmLite; // Db
namespace JiwaFinancials.Jiwa.JiwaServiceModel
{
public class RESTAPIPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaRESTAPIPlugin
{
public void Configure(JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin, ServiceStack.ServiceStackHost AppHost, Funq.Container Container, JiwaApplication.Manager JiwaApplicationManager)
{
AppHost.RegisterService<CustomServices>();
AppHost.Routes.Add(typeof(InventoryLimitFieldsRequest), "/Custom/InventoryLimitFields/{StartPosition}/{NumberRows}", "GET", "Retrieves inventory with limited fields, end and start specified.", "");
}
}
#region "Requests"
[ApiResponse(200, "Records retrieved OK")]
[ApiResponse(401, "Not authenticated")]
[ApiResponse(404, "Handler for Request not found")]
public class InventoryLimitFieldsRequest : IReturn<InventoryLimitFieldsResponse>
{
public int StartPosition { get; set; }
public int NumberRows { get; set; }
}
#endregion
#region "Responses"
[Serializable()]
public class InventoryLimitFieldsResponse : List<IN_Main>
{
}
#endregion
#region "Services"
public class CustomServices : Service
{
[Authenticate]
public InventoryLimitFieldsResponse Get(InventoryLimitFieldsRequest request)
{
return Db.SqlList<IN_Main>("SELECT LastSavedDateTime, InventoryID, PartNo, Description, Status, DefaultPrice, RRPPrice, Aux2, BackOrderable FROM IN_Main ORDER BY InventoryID OFFSET @StartPosition ROWS FETCH NEXT @NumberRows ROWS ONLY;",
new { StartPosition = request.StartPosition, NumberRows = request.NumberRows}).ConvertTo<InventoryLimitFieldsResponse>();
}
}
#endregion
}
It compiles not problem in the JIWA system. But I keep getting errors.
Any ideas?
Cheers