Page 1 of 1

An issue with IN_UnitOfMeasureQuery

PostPosted: Thu Sep 21, 2017 5:21 pm
by gkov3
Hi Mike,

I am trying to use auto generated IN_UnitOfMeasureQuery query to find a particular a particular PartNumber based on one of the packaging/UoM barcode, but the server is returning "Bad Request" with a message {"Index (zero based) must be greater than or equal to zero and less than the size of the argument list."}

Other queries are working fine e.g. IN_MainQuery and IN_CategoriesQuery.

Is this query available for use?

Sample code:
Code: Select all
client.Get( new IN_UnitOfMeasureQuery()
                                 {
                                     Barcode = "9987",
                                     Fields = "PartNo"
                                 }
                             ).Results.Select(t => t.PartNo).


Jiwa 7.0.187 (Self hosted REST API)

Regards,

Goran

Re: An issue with IN_UnitOfMeasureQuery

PostPosted: Thu Sep 21, 2017 5:48 pm
by Scott.Pearce
You need to add the route to the REST API plugin in Jiwa.

We don't add routes for every table/view/stored procedure in the database as SwaggerUI (v2) performance sucked with so many routes (SwaggerUI v3 may be better - we are waiting for a build of ServiceStack that includes this version). We add only what we feel are going to be the commonly used routes.

Here is what you need to add to the REST API plugin under the region Configuration->Routes->Queries - AutoQueries for Tables and Views in JiwaFinancials.Jiwa.JiwaServiceModel.Tables:

Code: Select all
AppHost.Routes.Add(typeof(IN_UnitOfMeasureQuery), "/Queries/IN_UnitOfMeasure", "GET", "Retrieves a list of units of measure.", "");


Remember that when a database is upgraded, standard plugins may be overwritten. If you are going to modify a standard plugin such as the shipped REST API plugin, make a copy of it, change the Author and/or Name, and edit that version.

Re: An issue with IN_UnitOfMeasureQuery  Topic is solved

PostPosted: Thu Sep 21, 2017 6:30 pm
by Mike.Sheen
Scott.Pearce wrote:Remember that when a database is upgraded, standard plugins may be overwritten. If you are going to modify a standard plugin such as the shipped REST API plugin, make a copy of it, change the Author and/or Name, and edit that version.


You can actually just create a new plugin to add routes, instead of editing our standard one (or copying our standard one and editing that) - that way you don't need to concern yourself with trying to merge changes into a copied version later on when we update our standard one.

In a new plugin, the only code you'd need to add an additional route for an existing table or view is as follows:
Code: Select all
using JiwaFinancials.Jiwa.JiwaServiceModel.Tables;

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.Routes.Add(typeof(IN_UnitOfMeasureQuery), "/Queries/IN_UnitOfMeasure", "GET", "Retrieves a list of units of measure.", "");
      }
   }
}


PS: And as Scott mentioned Swagger UI v2.2.10 which we ship with had an issue with so many routes when we had one for each table and view - but Swagger UI 3 seems to handle it much better - we're just needing the ServiceStack Swagger UI plugin to be updated - so in the future you may not need to use a Jiwa plugin to add routes for existing tables and views.

Re: An issue with IN_UnitOfMeasureQuery

PostPosted: Thu Sep 21, 2017 6:57 pm
by gkov3
Thank you guys. I think I understand now, what's going on.

Regards,

Goran