Hi,
I want to GET sales item’s Quantity with there Batches via Rest API, i can’t find DocType
Thanks
Hi,
I want to GET sales item’s Quantity with there Batches via Rest API, i can’t find DocType
Thanks
Try something like this on your terminal:
BASE_URL="https://erp.my_company.com"
TOKEN=$(echo -n "MY_API_KEY:MY_API_SECRET" | base64 -w 0)
ITEM_CODE="12345"
WAREHOUSE="My Warehouse"
curl --location --request GET "$BASE_URL/api/method/erpnext.stock.utils.get_stock_balance" \
--data-urlencode "item_code=$ITEM_CODE" \
--data-urlencode "warehouse=$WAREHOUSE" \
--header "Authorization: Basic $TOKEN"
This should return something like
{"message":150.0}
Edit: updated to include @revant_one’s solution.
echo -n "apfjxkic-omyuobwd339805ak:60a06cd2ddfad610b9490d359d605407" | base64 -w 0
Thanks,
This helps me
api/method/erpnext.stock.doctype.batch.batch.get_batch_qty?batch=[(batch]&warehouse=[warehouse]
https://gousiridev.frappe.cloud/api/method/erpnext.stock.utils.get_stock_balance(“Biostimulant-5”,“GS-Warehouse-Bengaluru”)
This is my API url
Error response I’m getting
{
"exc_type": "ValidationError",
"exception": "frappe.exceptions.ValidationError: Failed to get method for command erpnext.stock.utils.get_stock_balance(\"Biostimulant-5\",\"GS-Warehouse-Bengaluru\") with module 'erpnext.stock.utils' has no attribute 'get_stock_balance(\"Biostimulant-5\",\"GS-Warehouse-Bengaluru\")'",
"exc": "[\"Traceback (most recent call last):\\n File \\\"apps/frappe/frappe/handler.py\\\", line 65, in execute_cmd\\n method = get_attr(cmd)\\n File \\\"apps/frappe/frappe/handler.py\\\", line 226, in get_attr\\n method = frappe.get_attr(cmd)\\n File \\\"apps/frappe/frappe/__init__.py\\\", line 1447, in get_attr\\n return getattr(get_module(modulename), methodname)\\nAttributeError: module 'erpnext.stock.utils' has no attribute 'get_stock_balance(\\\"Biostimulant-5\\\",\\\"GS-Warehouse-Bengaluru\\\")'\\n\\nDuring handling of the above exception, another exception occurred:\\n\\nTraceback (most recent call last):\\n File \\\"apps/frappe/frappe/app.py\\\", line 69, in application\\n response = frappe.api.handle()\\n File \\\"apps/frappe/frappe/api.py\\\", line 55, in handle\\n return frappe.handler.handle()\\n File \\\"apps/frappe/frappe/handler.py\\\", line 38, in handle\\n data = execute_cmd(cmd)\\n File \\\"apps/frappe/frappe/handler.py\\\", line 67, in execute_cmd\\n frappe.throw(_(\\\"Failed to get method for command {0} with {1}\\\").format(cmd, e))\\n File \\\"apps/frappe/frappe/__init__.py\\\", line 511, in throw\\n as_list=as_list,\\n File \\\"apps/frappe/frappe/__init__.py\\\", line 479, in msgprint\\n _raise_exception()\\n File \\\"apps/frappe/frappe/__init__.py\\\", line 434, in _raise_exception\\n raise raise_exception(msg)\\nfrappe.exceptions.ValidationError: Failed to get method for command erpnext.stock.utils.get_stock_balance(\\\"Biostimulant-5\\\",\\\"GS-Warehouse-Bengaluru\\\") with module 'erpnext.stock.utils' has no attribute 'get_stock_balance(\\\"Biostimulant-5\\\",\\\"GS-Warehouse-Bengaluru\\\")'\\n\"]",
"_server_messages": "[\"{\\\"message\\\": \\\"Failed to get method for command erpnext.stock.utils.get_stock_balance(\\\\\\\"Biostimulant-5\\\\\\\",\\\\\\\"GS-Warehouse-Bengaluru\\\\\\\") with module 'erpnext.stock.utils' has no attribute 'get_stock_balance(\\\\\\\"Biostimulant-5\\\\\\\",\\\\\\\"GS-Warehouse-Bengaluru\\\\\\\")'\\\", \\\"title\\\": \\\"Message\\\", \\\"indicator\\\": \\\"red\\\", \\\"raise_exception\\\": 1}\"]"
}
I haven’t created any method like get_stock_balance
Please let me know if i have any solution
i need a rest api to fetch the item balance