Page 1 of 1

Request-URI Too Long

PostPosted: Thu Mar 14, 2019 12:46 pm
by SBarnes
Hi Mike

In trying to add an order through the web api we are getting an error that says "Request-URI Too Long" would it be correct to assume this is because this is an order with hundreds of lines in it and the only way to resolve the issue is to reduce the data being sent?

Re: Request-URI Too Long

PostPosted: Thu Mar 14, 2019 12:50 pm
by Mike.Sheen
I wouldn't have thought so as creating sales orders is a POST operation and so the URI doesn't contain the DTO, the body does - unless the content type has been overridden to application/x-www-form-urlencoded.

Are you able to see the request logs for any clues?

Re: Request-URI Too Long

PostPosted: Thu Mar 14, 2019 4:11 pm
by SBarnes
Hi Mike,

I actually now suspect the following code may be the culprit, after I saw more of the log, the customer has some very long part numbers and if the order was 500 lines long then that might explain it.

Code: Select all
              string[] parts = order.Details.Select(e => e.StockCode).ToArray();
                inqry.PartNoIn = parts;
                ServiceStack.QueryResponse<IN_Main> IN_MainQueryResponse;
                IN_MainQueryResponse = client.Get<ServiceStack.QueryResponse<IN_Main>>(inqry);
               
                foreach (DetailOrderLine line in order.Details)
                {
                    List<IN_Main> items = IN_MainQueryResponse.Results;
                    int count = items.FindAll(e => e.PartNo == line.StockCode && e.Status == 0).ToList().Count;
                    line.CodeExitsInJiwa = (count != 0);
                    line.InventoryID = count != 0 ? items.Find(e => e.PartNo == line.StockCode && e.Status == 0).InventoryID : "";
                    order.Log.Add("Checking in Jiwa for : " + line.StockCode);
                }
                LogoutGetRequest logout = new LogoutGetRequest();
                LogoutGetResponse lresp = client.Get<LogoutGetResponse>(logout);
                order.ChekcInJiwa = true;


What is the maximum length and is there a way to increase it?

Re: Request-URI Too Long  Topic is solved

PostPosted: Fri Mar 15, 2019 9:35 am
by Mike.Sheen
Right - so the problem is not a sales order operation, but the GET of parts with a given list of part numbers

Code: Select all
IN_MainQueryResponse = client.Get<ServiceStack.QueryResponse<IN_Main>>(inqry);


That would pass as parameters each Part No. - the request would be something like:

https://api.jiwa.com.au/Queries/IN_Main?PartNoIn=1170,1171


Where the PartNoIn parameter value is a csv separated list of parts you are retrieving - and if there are many and they are long, you'll exceed the maximum request length configured.

SBarnes wrote:What is the maximum length and is there a way to increase it?


The default maximum length I believe is 4MB - but you can override this in the JiwaAPISelfHostedService.exe.config file under the system.web section by setting the maxRequestLength attribute of the httpRuntime property - e.g.:

Code: Select all
<configuration>
   <system.web>
      <httpRuntime maxRequestLength ="2097151"/>
   </system.web>
</configuration>