## Issue Overview
The error code 9004010D in Power Pages server logic indicates a generic Common Data Service (CDS) error when invoking custom APIs via the Dataverse connector, often due to permission misconfigurations, missing site settings, or endpoint formatting issues. This occurs because server-side execution in Power Pages enforces stricter Dataverse access rules compared to client-side Web API calls, even if the custom action works in tools like XrmToolBox. In your code snippet, the `InvokeCustomApi` call to `accounts/{id}/Microsoft.Dynamics.CRM.new_function` is likely failing at the authentication or resource access layer.
## Root Cause Diagnosis
To identify the problem, start by checking table permissions in the Portal Management app: Ensure the "Accounts" table has appropriate Read/Write privileges assigned to the web role of authenticated users (or global if testing anonymously), as custom actions bound to entities require entity-level access. Next, verify site settings under WebAPI—add entries like `Webapi/accounts/enabled` (value: true) and `Webapi/accounts/fields` (value: * or specific fields like name, to expose required attributes for the action). If the custom action involves related entities or complex parameters, the CDS error can stem from unexposed fields or OData query restrictions; test by simplifying the payload to minimal inputs. Additionally, confirm the endpoint uses the correct plural logical name (e.g., "accounts") and that the action is published and bound properly in Dataverse.
## Troubleshooting Steps
Use browser developer tools (F12 > Network tab) to inspect the full request/response during server logic execution, which may reveal inner errors like 0x0 or attribute permission issues not shown in the console. Clear the portal cache after changes via the Portal Management app, then retry the invocation; if it persists, wrap the call in a try-catch to log detailed errors: `try { const response = await Server.Connector.Dataverse.InvokeCustomApi("POST", `accounts(${id})/Microsoft.Dynamics.CRM.new_function`, JSON.stringify(payload)); return JSON.parse(response); } catch (error) { console.error("Detailed error:", error); }`. For custom actions, ensure the action's input parameters match the payload structure exactly, and test with a simple action (e.g., one returning a string) to isolate if it's payload-related. If using N:N relationships or parental scopes in the action, append a FetchXML filter to the request to bypass query expansion errors.
## Workarounds and Recommendations
As a temporary workaround, fallback to client-side Web API calls using `webapi.safeAjax` for custom actions, but note this exposes logic to the browser and requires similar site settings. For production, consider installing the Power Pages Actions solution from GitHub to enable server-side custom API wrappers with better error handling. Microsoft documentation on server logic is indeed limited for this preview feature, so monitor the Power Platform release notes for updates and consider raising a support ticket via the admin center for deeper diagnostics. Testing in a dev environment with minimal payloads and escalating privileges temporarily can help pinpoint the issue.[9][5]
Best Regards,
Jerald Felix