I am trying to call an Apex method imperatively with complex parameters from a Lightning Web Component but I'm getting an http 500 response every time. Here is what I'm doing which is a copy of this recipe.

So I have a TestController with an action exposed and a couple of inner classes which are my request/response objects:

 public with sharing class TestController {
    public TestController() {


    public static TestResponse testAction(TestRequest req){
        return new TestResponse(req);

    public class TestResponse {
        @AuraEnabled public String testId {get; set;}

        public TestResponse(TestRequest req){
            this.testId = req.testId;

    public class TestRequest { 
        @AuraEnabled public String testId {get; set;}

The javascript code for the lwc is:

import { LightningElement, track } from "lwc";
import testAction from "@salesforce/apex/TestController.testAction";

export default class Test extends LightningElement {
    @track res;

        const request = { testId: "foo" };
        testAction({ req: request })
              .then(response => {
              .catch(error => {

And this is the response I always get from the server:

   statusText: "Server Error",
   ok: false,
   status: 500,
   body: {
   message: "An internal server error has occurred↵Error ID: 214808163- 
 50404 (1739684013)"
   headers: {}

It seems to be a problem when salesforce it's trying to bind what it's being sent from the client to the parameter object because it doesn't even reach the controller action.

UPDATE I am working on a scratch org, and have the component in a lightning community

  • Do your apex debug logs give you any error message?
    – Kasper
    Feb 21, 2020 at 10:51
  • nothing @Kasper
    – Daniel
    Feb 21, 2020 at 10:51

4 Answers 4


The problem looks like the combination of both Apex inner classes and a namespace.

  • With neither, a class name is e.g. MyOuter
  • With an inner class, a class name is e.g. MyOuter.MyInner
  • With a namespace, a class name is e.g. myNs.MyOuter
  • With both, a class name is e.g. myNs.MyOuter.MyInner

The both case - two dots - appears to be broken. So the workaround is to not use inner classes.

(Daniel is a colleague of mine.)

  • It took far too long to find this answer on google. Dec 31, 2021 at 2:23

I tried your code, and all work fine. It's very strange for me. Looks like problem with server connection. Try to deploy again your code.

  • I'm deploying to a scratch org through sfdx force:source:push. Could it be something with the org definition?
    – Daniel
    Feb 21, 2020 at 11:57
  • I have done it on scratch org - it is all right too.
    – Alexandr
    Feb 21, 2020 at 13:30
  • @Daniel Perhaps having a namespace set in the scratch org is the problem?
    – Keith C
    Feb 24, 2020 at 8:40
  • Alexandr, Did you test in a Community or a normal UI page?
    – Keith C
    Feb 24, 2020 at 9:57

I agree with @Alexandr. I have seen this issue come up when there is an issue with my Apex Controller that my LWC references. Try re-deploying your Apex Controller and LWC to confirm everything can push successfully. In my case, the params changed on another Apex Class that my Apex Controller was calling, and I didn't realize it until my Apex Controller failed to deploy. My error message was slightly different:

Error: apex://Apex_Controller_Name: No apex action available for Apex_Controller_Name.methodName↵

Internal Error: 500


Probably namespace. The only solution I found was to recieve the param as Object, then serialize it to Json and deserialize it using the inner class type.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .