4.5 KiB
Deploy Asset API to Frappe Server
Issue
When trying to create/edit/delete assets, you get an error: "Failed to save asset" or "Failed to create asset"
This happens because the Asset API endpoints are not deployed on your Frappe server yet.
Solution
Follow these steps to deploy the Asset API:
Step 1: SSH into Your Frappe Server
ssh user@seeraasm-med.seeraarabia.com
Replace user with your actual SSH username.
Step 2: Navigate to the Asset Lite App API Directory
cd frappe-bench/apps/asset_lite/asset_lite/api/
If the api directory doesn't exist, create it:
mkdir -p frappe-bench/apps/asset_lite/asset_lite/api/
cd frappe-bench/apps/asset_lite/asset_lite/api/
Step 3: Create the Asset API File
Create a new file called asset_api.py:
nano asset_api.py
Step 4: Copy the API Code
Copy the ENTIRE contents of the file frappe_asset_api.py from your project folder and paste it into the editor.
The file contains these API endpoints:
get_assets- Get list of assets with filtersget_asset_details- Get details of a specific assetcreate_asset- Create a new assetupdate_asset- Update an existing assetdelete_asset- Delete an assetget_asset_filters- Get filter optionsget_asset_stats- Get asset statisticssearch_assets- Search assets by keyword
Step 5: Save and Exit
In nano:
- Press
Ctrl + O(to save) - Press
Enter(to confirm) - Press
Ctrl + X(to exit)
Step 6: Create init.py (if needed)
Make sure there's an __init__.py file in the api directory:
touch __init__.py
Step 7: Restart Frappe
Go back to the bench directory and restart:
cd ~/frappe-bench
bench restart
Or if using supervisor:
sudo supervisorctl restart all
Step 8: Test the API
Open your browser console and try creating an asset again. You should now see detailed logs:
[useAssetMutations] Creating asset with data: {...}
[useAssetMutations] Create asset response: {...}
Verify Deployment
You can verify the API is deployed by checking if the endpoint exists:
curl -X GET "https://seeraasm-med.seeraarabia.com/api/method/asset_lite.api.asset_api.get_assets?limit=1"
You should get a response (even if it's an authentication error, that means the endpoint exists).
Troubleshooting
Error: "Module has no attribute 'asset_api'"
Cause: The file wasn't created in the right location or Frappe hasn't reloaded.
Solution:
- Check the file exists:
ls -la ~/frappe-bench/apps/asset_lite/asset_lite/api/asset_api.py - Restart Frappe:
cd ~/frappe-bench && bench restart
Error: "Not permitted to create asset"
Cause: Your user doesn't have permissions for the Asset doctype.
Solution:
- Log in to Frappe desk as Administrator
- Go to User Permissions
- Grant your user "Create" permission for Asset doctype
Error: "Asset doctype not found"
Cause: The Asset Lite app doesn't have an Asset doctype, or it's named differently.
Solution: Check what doctypes are available:
cd ~/frappe-bench
bench console
Then in the console:
import frappe
frappe.get_all('DocType', filters={'module': 'Asset Lite'}, fields=['name'])
You may need to adjust the doctype name in the API code.
Expected Behavior After Deployment
✅ Create Asset: Form data is saved, new asset is created with auto-generated ID ✅ Edit Asset: Changes are saved to existing asset ✅ Delete Asset: Asset is deleted after confirmation ✅ Duplicate Asset: New asset is created based on existing one ✅ Export/Print: Asset data is exported or printed
Console Debugging
After deployment, when you try to save an asset, you should see in the browser console:
[useAssetMutations] Creating asset with data: {
asset_name: "Test Asset",
company: "Test Company",
custom_asset_type: "Medical Equipment",
// ... other fields
}
[useAssetMutations] Create asset response: {
success: true,
asset: { name: "ACC-ASS-2025-00097", ... },
message: "Asset created successfully"
}
If you see errors instead, they will now show the actual backend error message.
Need Help?
If you continue having issues:
- Check the Frappe error logs:
tail -f ~/frappe-bench/logs/error.log - Check the worker logs:
tail -f ~/frappe-bench/logs/worker.error.log - Verify your user has the correct permissions in Frappe
- Make sure the Asset doctype exists in your Asset Lite app