ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Grid filled thru API and (filtered) displayed on a Default Form


#1

Dear all,

I’m trying to display on the ERPNext Item Master the Stock-Level Details from SAP. I’m using ERPNext RESTful API to synchronize the Item Master. I would like to avoid a separate HTTP call for each Item Movement on each Item Master, as this would impact performance and other potential issues. What I was thinking about is as follows:

A: Create a new single Form Type in ERPNext which will be ‘replaced’ (deleted and re-created) on a scheduled base thru the RESTful API with all the SAP Items and Stock Quantities. It should be like a single Grid/Table which just will be filled via 1 single HTTP Call e.g. once a day.

B: This Form Type Grid will also hold the ERPNext Item Code as a column. On the ERPNext Item Master I would like then to display (read only) a section with the Stock Level Grid, filtered by the Current Item Master Code.

Do you think something like that is possible? Or would you know about any other convenient solution of how to update Stock Level Detail Information on the ERPNext Item Master without having to send a separate HTTP Call for each Item?

Thanks, David


#2

@David_Stegnitz you need to just push a Stock Reconciliation record to sync stock balances.


#3

@rmehta thank you, that works very fine. The only restriction I can foresee would be in case a Customer has a batch or serial number Products. I’ll think about once it becomes current.


#4

@rmehta Good morning, I hit the next issue with the Stock Reconciliation Document API. I’m not sure if this is a general restriction and if this can be changed, but it looks like the maximum array rows in the ‘Items’ area is about 20 only. When I try to create a Stock Reconciliation Document with more about 30 Items, I’m getting the following return Error Message:

"

Bad Request

Bad Request

Request Line is too large (4367 > 4094) "

When I try it with 20 Items, everything is working fine and the Document was created.

I then tried the same with a Sales Order, until now I was always testing with just a few lines. When trying to send a Sales Order with about 25 lines, I’m getting the same error:

"returnData

Bad Request

Bad Request

Request Line is too large (5344 > 4094) returnData"

Could you advise of any setting which can change that restriction? We will have common documents with more than 25 lines.

Thanks, David


Here still the original Request call:

{“transaction_date”:“20151108”,“delivery_date”:“20151108”,“customer”:“Test David 99”,“po_no”:"",“discount_amount”:1131.400000,“sap_sync_setting”:“Updates synced”,“sap_sync_message”:“Successfully synced from SAP, DocNum:409”,“sap_last_sync_time”:“2015-11-10-04:42:20”,“sap_id”:“409”,“items”:[{“item_code”:“140-005”,“qty”:10.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:12.000000,“discount_percentage”:5.000000},{“item_code”:“S10000”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:1840.000000,“discount_percentage”:0.000000},{“item_code”:“NewItem111”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:0.000000,“discount_percentage”:0.000000},{“item_code”:“David123”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:0.000000,“discount_percentage”:0.000000},{“item_code”:“A00001”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:400.000000,“discount_percentage”:0.000000},{“item_code”:“140-005”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:0.000000,“discount_percentage”:0.000000},{“item_code”:“S10000”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:1840.000000,“discount_percentage”:0.000000},{“item_code”:“NewItem111”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:0.000000,“discount_percentage”:0.000000},{“item_code”:“David123”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:0.000000,“discount_percentage”:0.000000},{“item_code”:“A00001”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:400.000000,“discount_percentage”:0.000000},{“item_code”:“140-005”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:0.000000,“discount_percentage”:0.000000},{“item_code”:“S10000”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:1840.000000,“discount_percentage”:0.000000},{“item_code”:“NewItem111”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:0.000000,“discount_percentage”:0.000000},{“item_code”:“David123”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:0.000000,“discount_percentage”:0.000000},{“item_code”:“A00001”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:400.000000,“discount_percentage”:0.000000},{“item_code”:“140-005”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:0.000000,“discount_percentage”:0.000000},{“item_code”:“140-005”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:0.000000,“discount_percentage”:0.000000},{“item_code”:“A00001”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:400.000000,“discount_percentage”:0.000000},{“item_code”:“David123”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:0.000000,“discount_percentage”:0.000000},{“item_code”:“NewItem111”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:0.000000,“discount_percentage”:0.000000},{“item_code”:“S10000”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:1840.000000,“discount_percentage”:0.000000},{“item_code”:“S10000”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:1840.000000,“discount_percentage”:0.000000},{“item_code”:“NewItem111”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:0.000000,“discount_percentage”:0.000000},{“item_code”:“David123”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:0.000000,“discount_percentage”:0.000000},{“item_code”:“A00001”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:400.000000,“discount_percentage”:0.000000},{“item_code”:“140-005”,“qty”:1.000000,“warehouse”:“Finished Goods - OP365”,“price_list_rate”:0.000000,“discount_percentage”:0.000000}]}


#5

This is a gunicorn setting named “limit_request_line”. Change it with --limit-request-line bigger_number.

See http://docs.gunicorn.org/en/latest/settings.html?highlight=limit_request_line for details.


#6

Thank you @NoumirPoutipou for your response on this. I tried to find the setting but was unable to do so. It tells me that gunicorn isn’t even installed. I created a job posting on the ERPNext Job Portal, please feel free to bit on it:

https://community.erpnext.com/jobs/change-limit_request_line-for-http-restful-calls

Thanks, David


#7

so far we weren’t able to identify the setting or remove the character limitation of the HTTP Call Query. Much appreciated if somebody could guide me thru it or have another input. I’m open for a paid service on this. Thanks.


#8

@David_Stegnitz are you sending GET request by any chance?


#9

@rmehta I’m using POST method request for Inserts and PUT method for Updates.


Crash ERPNext v11 when acces option "Data export"
#10

I got it working out with the help of a Linux expert. I’m sharing the solution documentation as follows:

Below is the description of workaround I made:

Issue: Issue with the Stock Reconciliation Document API calls: “Bad Request: Request Line is too large” for Documents with more about 30 items.

Root cause: By default, client’s HTTP request-line is limited by 4094 characters and API call above overcome this limit.

Workaround: Changed limit-request-line option for wsgi web server to unlimit size of a client’s HTTP request-line.

Description:

Added option --limit-request-line 0 into wsgi server startup line.

Config file [/home/erpnext/frappe-bench/config/supervisor.conf]:
line 2> command=/home/erpnext/frappe-bench/env/bin/gunicorn -b 127.0.0.1:8000 -w 2 -t 120 --limit-request-line 0 frappe.app:application

In order to apply changes restart wsgi server:

sudo supervisorctl reload

Additional info:

Gunicorn settings:

Security

limit_request_line

–limit-request-line INT
4094
The maximum size of HTTP request line in bytes.

This parameter is used to limit the allowed size of a client’s HTTP request-line. Since the request-line consists of the HTTP method, URI, and protocol version, this directive places a restriction on the length of a request-URI allowed for a request on the server. A server needs this value to be large enough to hold any of its resource names, including any information that might be passed in the query part of a GET request. Value is a number from 0 (unlimited) to 8190.

This parameter can be used to prevent any DDOS attack.