web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Pages - Customize & Extend
Suggested Answer

new Server logic InvokeCustomApi not working

(0) ShareShare
ReportReport
Posted on by 20
Hi,
 
I'm trying the new server logic in power pages.
 
I try the InvokeCustomApi function like:
 
        const response = await Server.Connector.Dataverse.InvokeCustomApi("POST", "accounts(" + id + ")/Microsoft.Dynamics.CRM.new_function", JSON.stringify(payload));
        return JSON.parse(response);
 
I receive this error:
{"error":{"code":"9004010D","message":"Common Data Service error occurred.","cdscode":""}
 
the function is working fine when I call it using REST builder in the xrmtoolbox.
 
how to diagnose the problem and identify the root cause for the error?
as it's a new feature, the level of documentation and samples from Microsoft is very low, but maybe somebody has more info to share?
 
thanks.
Categories:
I have the same question (0)
  • Suggested answer
    Jerry-IN Profile Picture
    267 on at
    new Server logic InvokeCustomApi not working
    Hello ,
     
    ## 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
  • Willgart Profile Picture
    20 on at
    new Server logic InvokeCustomApi not working
    thanks for the detailed feedback.
     
    I changed the security to allow write access to the accounts table, no change, same error.
     
    for testing, I authorized anonymous access to the site and to the server logic end point.
    So I can test the server logic through the url directly
    the server logic works fine if I'm not calling InvokeCustomApi.
    I can read records, I can update records etc... but I can't call my new_function
     
    I checked the parameters sent to the custom API, and they are working fine when I execute from the xrmtoolbox.
    I copy/paste them without any improvement.
     
    well I'll open a ticket later, for now I'm testing and I'm suffering other limitations for my needs, so far away from using SPA.
  • Nagesh Profile Picture
    Microsoft Employee on at
    new Server logic InvokeCustomApi not working
    This is a bug and fix is getting rolled out. Fix should reach all stations by November end.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Coming soon: forum hierarchy changes

In our never-ending quest to improve we are simplifying the forum hierarchy…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Pages

#1
Jerry-IN Profile Picture

Jerry-IN 64

#2
Fubar Profile Picture

Fubar 46 Super User 2025 Season 2

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 27 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics