Page 1 of 1

API Error in Getting SOH in 7.185

PostPosted: Thu Aug 24, 2017 7:38 pm
by SBarnes
Hi Mike,

I am getting an error in trying to get the SOH for an Inventory Item the error is "Index (zero based) must be greater than or equal to zero and less than the size of the argument list." I am not sure if it's something I am doing wrong or a possible bug in the API?

The code producing the error reads as

Code: Select all
                   IN_SOHQuery sohqry = new IN_SOHQuery();
                    sohqry.InventoryID = InventoryID;
                    //sohqry.QuantityLeftGreaterThan = 0;


                    ServiceStack.QueryResponse<IN_SOH> IN_SOHQueryResponse;
                    IN_SOHQueryResponse = client.Get<ServiceStack.QueryResponse<IN_SOH>>(sohqry);

Re: API Error in Getting SOH in 7.185  Topic is solved

PostPosted: Thu Aug 24, 2017 9:05 pm
by Mike.Sheen
Hi Stuart,

I'll look into it - but before I do can you provide your code which added the route? Whilst we do provide the Query classes for all tables, in order for that to be accessible a route needs to be added via plugin otherwise you should get a 404.

We would have liked to have added routes for all our query classes, but when we did so we found the SwaggerUI had problems with that many routes (ServiceStack handled it like a champ, but the version of SwaggerUI used does not) - so we scaled back the number of routes we publish by default in our standard REST API plugin.

Mike

Re: API Error in Getting SOH in 7.185

PostPosted: Thu Aug 24, 2017 9:28 pm
by SBarnes
Thanks Mike,

Don't bother yourself any further that explains what I just discovered that its not showing up in in the Swagger UI, and I hadn't considered there was no route in the plugin.

It explains why almost identical code IN_MainQuery works and this doesn't.

But its not producing a 404 its producing a 400 Bad Request in the log hence the reason I had assumed there was a route defined.

As always thanks for the quick response.

Re: API Error in Getting SOH in 7.185

PostPosted: Thu Aug 24, 2017 9:30 pm
by Mike.Sheen
SBarnes wrote:But its not producing a 404 its producing a 400 Bad Request in the log hence the reason I had assumed there was a route defined.


Ok - thanks for letting me know - I'll see what we can do to make it return the more expected 404.

Re: API Error in Getting SOH in 7.185

PostPosted: Fri Aug 25, 2017 9:20 am
by SBarnes
Hi Mike

Just to close the topic, you were right adding the code below in a separate plugin and refreshing the service reference fixed the issue completely.

If I could make a small suggestion would there be any advantage (if this is possible) to have the build process generate a plugin for the database that would contain all the extra routes but commented out so that it would then just be a matter of uncommenting the ones you want and enabling the plugin given this would probably guarantee consistency and the proper "RESTful" URLs, I realise time constraints may not make this possible at the moment?

As always thanks for the help.

Code: Select all
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_SOHQuery), "/Queries/IN_SOH", "GET", "Retrieves a list of SOH Entries.", "");
       }
        
 
   }

}