Declarative node returns "ToUpperCase not a function" error

Describe the problem/error/question

I am attempting to build a custom declarative node for my company’s public api and want to begin by just getting the body of the API endpoint. I’ve run into an issue with axios, which I see is a node_module, but don’t entirely know what it is and how to fix it. I didn’t have the issue when following the tutorial for the declarative style nodes. I’m using npm and not pnpm since I ran into other issues with that along the way.

What is the error message (if any)?

axiosRequest.method.toUpperCase is not a function

Please share your workflow

Share the output returned by the last node

axiosRequest.method.toUpperCase is not a function

Information on your n8n setup

  • n8n version: 1.81.4
  • Database (default: SQLite): Default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npm
  • Operating system: Windows 10

Do you know if you could provide the raw JSON of the setup? For some reason the local n8n renderer isn’t showing your node. Could be version mismatch.

And could you provide the exact error?

If it is saying can’t access toUpperCase on null, that implies that the issue is with the object earlier on, that it isn’t a string, as toUpperCase is a correct function.

Yes here is the raw JSON:
{
“nodes”: [
{
“parameters”: {
“endpoint”: “token”,
“requestOptions”: {}
},
“type”: “CUSTOM.MomentumAmp”,
“typeVersion”: 1,
“position”: [
220,
0
],
“id”: “8723303e-d752-4e45-9113-19b7c45bfe95”,
“name”: “Momentum AMP”,
“credentials”: {
“MomentumAmpApi”: {
“id”: “dxRGUp5DymQH7JMt”,
“name”: “Momentum Amp account”
}
}
}
],
“connections”: {},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “41adb91b9df4c894aec5db0091a45186876a9c01ab8a4c6ba29bf31f5996a462”
}
}

And here is the full error that shows:
Stack trace

NodeApiError: axiosRequest.method.toUpperCase is not a function at ExecuteSingleContext.httpRequestWithAuthentication (C:\Users\Owner\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\execution-engine\node-execution-context\utils\request-helper-functions.ts:1314:9) at ExecuteSingleContext.httpRequestWithAuthentication (C:\Users\Owner\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\execution-engine\node-execution-context\utils\request-helper-functions.ts:1686:11) at RoutingNode.rawRoutingRequest (C:\Users\Owner\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\execution-engine\routing-node.ts:568:20) at RoutingNode.makeRequest (C:\Users\Owner\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\execution-engine\routing-node.ts:762:19) at async Promise.allSettled (index 0) at RoutingNode.runNode (C:\Users\Owner\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\execution-engine\routing-node.ts:273:29) at ExecuteContext.versionedNodeType.execute (C:\Users\Owner\AppData\Roaming\npm\node_modules\n8n\src\node-types.ts:67:18) at WorkflowExecute.runNode (C:\Users\Owner\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\execution-engine\workflow-execute.ts:1123:8) at C:\Users\Owner\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\execution-engine\workflow-execute.ts:1470:27 at C:\Users\Owner\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\execution-engine\workflow-execute.ts:2029:11

Oh is this a custom app for n8n?

Yes it’s a custom declarative node/app

Do you have access to the code? It’s definitely an internal code issue then with the custom node.

Yes I have my code, I’m only working on authentication and the actual node. I’m simply trying to recreate the API enpoint of the first api from here https://docs.google.com/document/d/11Xk7TviRujq806pLK8pQTcdzDF2ClmPvkfnVmdh1bGc/edit?tab=t.0

//node
import { INodeType, INodeTypeDescription, INodeInputConfiguration, INodeOutputConfiguration } from 'n8n-workflow';

export class MomentumAmp implements INodeType {
    description: INodeTypeDescription = {
        displayName: 'Momentum Amp',
        name: 'MomentumAmp',
        icon: 'file:momentumamp.svg',
        group: ['transform'],
        version: 1,
        subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
        description: 'Get data from Momentum AMPs API',
        defaults: {
            name: 'Momentum AMP',
        },
        inputs: [{ type: 'main' } as INodeInputConfiguration],
        outputs: [{ type: 'main' } as INodeOutputConfiguration],
        credentials: [
            {
                name: 'MomentumAmpApi',
                required: true,
            },
        ],
        requestDefaults: {
            baseURL: 'https://api.nowcerts.com/api/',
            headers: {
                Accept: 'application/json',
                'Content-Type': 'application/json',
            },
        },
        
        //Required fields
        properties: [
            {
                displayName: 'API Endpoint',
                name: 'endpoint',
                type: 'options',
                placeholder: 'Select an endpoint',
                required: true,
                description: 'The API endpoint you want to reach.',
                options: [
                    {
                        name: 'Get Api Token',
                        value: 'token',
                    },
                ],
                default: '',
            },
        ],
    };
	
}

//authentication
import {
    IAuthenticateGeneric,
    ICredentialType,
    INodeProperties,
} from 'n8n-workflow';

export class MomentumAmpApi implements ICredentialType {
    name = 'MomentumAmpApi';
    displayName = 'Momentum Amp API';
    documentationUrl = 'https://docs.google.com/document/d/11Xk7TviRujq806pLK8pQTcdzDF2ClmPvkfnVmdh1bGc/edit?tab=t.0';
    properties: INodeProperties[] = [
        {
            displayName: 'Username',
            name: 'username',
            type: 'string',
            default: '',
        },
        {
            displayName: 'Password',
            name: 'password',
            type: 'string',
            typeOptions: { password: true },
            default: '',
        },
        {
            displayName: 'Client ID',
            name: 'clientId',
            type: 'string',
            default: 'ngAuthApp', // Default as per API docs
        },
    ];

    authenticate = {
        type: 'generic',
        properties: {
            method: 'POST',
            url: 'token',
            body: {
                grant_type: 'password',
                username: '={{$credentials.username}}',
                password: '={{$credentials.password}}',
                client_id: '={{$credentials.clientId}}',
            },
        },
    } as IAuthenticateGeneric;
}

Interesting. So the error implies method isn’t a string or isn’t setup right. I’d validate that in your node design.

based on the error given( ```
NodeApiError: axiosRequest.method.toUpperCase is not a function at ExecuteSingleContext.httpRequestWithAuthentication (C:\Users\Owner\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\execution-engine\node-execution-context\utils\request-helper-functions.ts:1314:9) at ExecuteSingleContext.httpRequestWithAuthentication (C:\Users\Owner\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\execution-engine\node-execution-context\utils\request-helper-functions.ts:1686:11) at RoutingNode.rawRoutingRequest (C:\Users\Owner\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\execution-engine\routing-node.ts:568:20) at RoutingNode.makeRequest (C:\Users\Owner\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\execution-engine\routing-node.ts:762:19) at async Promise.allSettled (index 0) at RoutingNode.runNode (C:\Users\Owner\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\execution-engine\routing-node.ts:273:29) at ExecuteContext.versionedNodeType.execute (C:\Users\Owner\AppData\Roaming\npm\node_modules\n8n\src\node-types.ts:67:18) at WorkflowExecute.runNode (C:\Users\Owner\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\execution-engine\workflow-execute.ts:1123:8) at C:\Users\Owner\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\execution-engine\workflow-execute.ts:1470:27 at C:\Users\Owner\AppData\Roaming\npm\node_modules\n8n\node_modules\n8n-core\src\execution-engine\workflow-execute.ts:2029:11


Here are the step-by-step instructions: [futurminds/n8n-self-hosting](https://github.com/futurminds/n8n-self-hosting)

You still won't be able to solve the mystery of why Nowcerts webhooks send only 1% of the time though ......That issue pretty much kills all real time integrations with Nowcerts.  Basically, you will be restricted to only GET/POST request for consistent and reliable data transfers until Nowcerts acknowledges that this major bug exists.   When webhooks do send, they sometimes can take between 30 min to 2 hours after the update occurs to fire the webhook, if and when it fires at all.  Many important updates such as Insured_create, and Insured update simply do not fire at all.  You cannot rely on their webhooks for data updates.  You will need to build any integrations with GET requests to pull the entire database of every endpoint daily, or hourly until they resolve the webhook issues. Until then, since Nowcerts does not seem rate-limit their API, just pull the entire database every 5 min.  This will resolve most webhook related issues.  I pretty much have every Nowcerts GET/POST Endpoint Built out  with detailed Descriptions for both AI Agents and MCP triggers.  Let me know if you would like to work together to build something amazing!