Issue trying to call whitelisted PY function in Custom App

Can you provide the screenshot of your code in work_order.py and file structure in directory work_order?

I believe that run_method is used for running Doc’s methods. I can see that your method is written outside the DocType’s Class Declaration even though its present in side the Class’s Py file.

So instead of using “url” attribute, try specifying “method” as below:
"method": "custom_app.custom_app.doctype.work_order.work_order.stop_unstop"

Assuming that the dotted path is the one you could import from bench console.

I receive the same error: Not found. The resource you are looking for is not available

error in your python logic you check that first by postman…

The source code in work_order.py is the following:

The file structure in directory work_order is:

I have used both attributes and it is still returning the same error. Still, I can import the function with the bench console command.

after you modified the code, have you restarted bench?

Yes, I restarted it using bench restart command

There it is… your path should be custom_app.work_order.doctype.work_order.work_order.stop_unstop Note the change in path from custom_app to work_order. This part of path generally indicates module name.

The anatomy of path is generally
<app name>.<module_name>.doctype.<doctype folder name>.<doctype file name>.<method name>

3 Likes

Thank you very much @VamYip
At last I can use the PY functions written for my custom application :blush:

Worked for me thankyou