MoralisError [Moralis SDK Core Error]: [C0006] Request failed, Bad Request(400): chain must be a valid enum value

It was working perfectly fine, then I opened this project a month later, and now it’s throwing me an error that “chain must be a valid enum value”.

return new CoreError({
                   ^

MoralisError [Moralis SDK Core Error]: [C0006] Request failed, Bad Request(400): chain must be a valid enum value        
    at RequestController.makeError (C:\Users\yuvir\Desktop\DEV\WEB 3.0\PayMate\server\node_modules\@moralisweb3\common-co
re\lib\cjs\index.cjs:1224:20)
    at RequestController.<anonymous> 

I am using the latest SDK “^2.26.1” .
I’ve rechecked my moralis API_KEY a thousand times.
Can’t seem to understand what’s the issue here.

app.get("/getNameAndBalance", async (req, res) => {  
  const { userAddress } = req.query;

  const response = await Moralis.EvmApi.utils.runContractFunction({
    chain: "0x13881", // hex index for the mumbai testnet
    address: "smart-contract-address", //smart contract address
    functionName: "getMyName", 
    abi: ABI,
    params: { _user: userAddress },
  });

This is what I’m trying to do.

this is not working any more because Mumbai testnet was removed, it is not longer supported as an evm chain, new chains replaced it for polygon/mumbai testnet

Oh, Okay. Thank you very much for responding.
I am new to blockchain. Should I migrate to Amoy now or is there a better one I should consider?

you can try Amoy chain now

Okay, so I have deployed my contract to Amoy now and verified it.
But whenever I call my getNameandBalance route it throws back a long object and crashes the server. The end of the object looks something like this.

          ],
          'user-agent': [ 'User-Agent', 'axios/1.6.8' ],
          'content-length': [ 'Content-Length', '2128' ],
          'accept-encoding': [ 'Accept-Encoding', 'gzip, compress, deflate, br' ],
          host: [ 'Host', 'deep-index.moralis.io' ]
        },
        [Symbol(errored)]: null,
        [Symbol(kHighWaterMark)]: 16384,
        [Symbol(kRejectNonStandardBodyWrites)]: false,
        [Symbol(kUniqueHeaders)]: null
      },
      data: { message: 'Invalid chain' }
    }
  }
}

I am using amoy chain id and everything but still encountering this issue.

app.get("/getNameAndBalance", async (req, res) => {  
  const { userAddress } = req.query;

  const response = await Moralis.EvmApi.utils.runContractFunction({
    chain: "0x13882", // hex index for the amoy testnet
    address: "smart-contract-address", //smart contract address
    functionName: "getMyName", 
    abi: ABI,
    params: { _user: userAddress },
  });

meanwhile, we removed that runContractFunction from the list of supported apis.

You could do it with a rpc node request, to call a function on a contract