Nick
#1
I tried using following code as directed at https://frappe.github.io/frappe/user/guides/integration/rest_api.html
But I am getting errors. I wish to fetch price for item_code via REST API.
$urls = ‘Frappe Cloud Price/?filters=[“Item%20Price”, “item_code”, “=”, “bk1”]"’;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $urls);
curl_setopt ($ch, CURLOPT_COOKIEFILE, COOKIE_FILE);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$ipjson = curl_exec($ch);
print $ipjson;
curl_close ($ch);
Error:
Bad Request
Invalid HTTP Version ‘Invalid HTTP Version: ‘“item_code”, “=”, “bk1”]" HTTP/1.0’’
I tried changing URL but still theres an error.
$urls = ‘Frappe Cloud Price/filters=[“Item%20Price”, “item_code”, “=”, “bk1”]"’;
Error:
Not Found
./domain.erpnext.com/site_config.json does not exist
Your formatting for filters is wrong. You are missing a set of square brackets and you have an extra quotation on the end.
try this:
$urls = 'Frappe Cloud Price/?filters=[[“Item%20Price”, “item_code”, “=”, “bk1”]]`;
Nick
#3
Thanks Ben.
I corrected and tried according to your reply. But still its not getting through. Error appears.
Bad Request
Invalid HTTP Version ‘Invalid HTTP Version: ‘“item_code”, “=”, “bk1”]] HTTP/1.0’’
I had a mistake in my suggestion. You have an extra forward slash before the ?:
$urls = 'https://domain.erpnext.com/api/resource/Item%20Price?filters=[["Item%20Price", "item_code", "=", "bk1"]]`;
A couple other suggestions if this doesn’t work:
- Have you made sure your URL is encoded properly (so that quotations/spaces are properly handled)?
- Have you logged in? What URL did you use for logging in?