REST API DoesNotExistError | desk > tools returns Server Error

I was trying to test my whitelisted methods, but whenever I use the URL: http://localhost:8000/api/, it returns the following error:

Server Error
Traceback (most recent call last):
File “/home/ghadeer/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 60, in application
response = frappe.api.handle()
File “/home/ghadeer/frappe/frappe-bench/apps/frappe/frappe/api.py”, line 127, in handle
raise frappe.DoesNotExistError
DoesNotExistError

What is the problem ??

http://localhost:8000/api in the browser returns:

Page missing or moved
We are very sorry for this, but the page you are looking for is missing (this could be because of a typo in the address) or moved.

Any help ?!

Could you share your code?

What are you trying to do?

Actually the problem is not in my code, the same code was working with no errors.

There is another error that appears in the desk, tools >

Traceback (most recent call last):
File “/home/ghadeer/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 55, in application
response = frappe.handler.handle()
File “/home/ghadeer/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 19, in handle
execute_cmd(cmd)
File “/home/ghadeer/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 40, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/ghadeer/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 896, in call
return fn(*args, **newargs)
File “/home/ghadeer/frappe/frappe-bench/apps/frappe/frappe/desk/moduleview.py”, line 14, in get
data = get_data(module)
File “/home/ghadeer/frappe/frappe-bench/apps/frappe/frappe/desk/moduleview.py”, line 30, in get_data
data = build_config_from_file(module)
File “/home/ghadeer/frappe/frappe-bench/apps/frappe/frappe/desk/moduleview.py”, line 54, in build_config_from_file
data += get_config(app, module)

I can’t help you unless you share your code or explain what are you trying to do!

OK …

I have for example this method in my project:

@frappe.whitelist(allow_guest=True)
def update_product(product_name,product_price,product_image,product_id):
    product = frappe.get_doc("products","%s" % (product_id))
    product.product_name = product_name
    product.product_price = product_price
    product.product_image = product_image

    product.save()

I used to call it using REST API like this:
localhost:8000/api/method/matajer.update_order?order_name=ORD-00002&order_price=500&customer_id=000&status=Unpaid&product_name=Test&product_price=200&product_image=pdpd.jpg

and it was working very well, but now and after doing bench update, when I try the same link it returns:
404 Not found error

Not Found
Invalid method

and I am sure that the link is correct, so I started testing the api itself typing localhost:8000/api/ and it always give me server error that it does not exist !

The same is happening with all the methods that I am trying to call using REST api !!

Thank you for your help !

Dont use Remote Procedure Calls (RPC) for CRUD
Use REST API instead for update

try this as PUT request:

http://localhost:8000/api/resource/Product/000000008

where is product_id = 000000008 :point_up_2:

Body:

data={"product_name": "xxxx","product_price":"yyyyy","product_image":"zzzzz"}

Thank you, it worked.

Glad it is works, you are welcome.