API Error in Getting SOH in 7.185  Topic is solved

Discussions relating to the REST API of Jiwa 7.

API Error in Getting SOH in 7.185

Postby SBarnes » Thu Aug 24, 2017 7:38 pm

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);
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1620
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

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

Postby Mike.Sheen » Thu Aug 24, 2017 9:05 pm

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
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2445
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 757

Re: API Error in Getting SOH in 7.185

Postby SBarnes » Thu Aug 24, 2017 9:28 pm

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.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1620
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: API Error in Getting SOH in 7.185

Postby Mike.Sheen » Thu Aug 24, 2017 9:30 pm

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.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2445
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 757

Re: API Error in Getting SOH in 7.185

Postby SBarnes » Fri Aug 25, 2017 9:20 am

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.", "");
       }
        
 
   }

}
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1620
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to REST API

Who is online

Users browsing this forum: No registered users and 2 guests