N8n custom node tutorial

Describe the problem/error/question

I am trying ti build a customised node and am following the n8n declarative tutorial which calls the nasa api. I have finished writing the code but am getting a 403 error for some reason and am unable to track the source of this error.

What is the error message (if any)?

HTTP Code

403

Stack

NodeApiError: Request failed with status code 403
    at RoutingNode.runNode (/Users/aaditroychowdhury/.nvm/versions/node/v18.7.0/lib/node_modules/n8n/node_modules/n8n-workflow/src/RoutingNode.ts:221:11)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Workflow.runNode (/Users/aaditroychowdhury/.nvm/versions/node/v18.7.0/lib/node_modules/n8n/node_modules/n8n-workflow/src/Workflow.ts:1334:11)
    at /Users/aaditroychowdhury/.nvm/versions/node/v18.7.0/lib/node_modules/n8n/node_modules/n8n-core/src/WorkflowExecute.ts:952:29

Please share your workflow

{
“meta”: {
“instanceId”: “fcd038091a45b2fcc2c169311b6f49b5065e2d9f590f8c72aa493fa1ad702dba”
},
“nodes”: [
{
“parameters”: {
“resource”: “marsRoverPhotos”,
“marsRoverDate”: “2023-06-13T18:30:00.000Z”
},
“id”: “0132c11e-0ece-43bb-9412-eaea4aabc76f”,
“name”: “NASA Pics”,
“type”: “n8n-nodes-nasapics.NasaPics”,
“typeVersion”: 1,
“position”: [
840,
380
],
“credentials”: {
“NasaPicsApi”: {
“id”: “1”,
“name”: “NASA Pics account”
}
}
}
],
“connections”: {}
}

Share the output returned by the last node

Information on your n8n setup

  • v18
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via npm:
  • Operating system: macOS

Seems like your custom node might be getting a 403 response from the external API it is calling.

Seeing you mentioned a tutorial in your post, have you checked out this video from our chief node builder @marcus?

1 Like

hi @MutedJam . thanks for the reference. However, I am still attaching the official tutorial site in case you find any discrepancies in it.

Oh, so what you are saying is that following the exact tutorial leads to the error you have seen? Can you share your project folder so we can take a closer look?

Hey @Batman,

A 403 could be that your credential data is incorrect. I would also recommend using Node 16 which is what we currently support.

1 Like

hey @MutedJam. I am attaching the link to the github repository as the folder is not being accepted here for some reason.
github project repository
Hope this helps.

Hey @Jon. I changed the node version. However, I am getting the same error.

The link doesn’t appear to work, is it private? Did you double check your credentials as well?

my bad @Jon. I am attaching the link again. The credentials seem fine to me.
I tried to redo the entire thing and now the node does not even appear as an option on the n8n node options.
project repository

Hey @Batman,

The repo doesn’t appear to have the tutorial node in it, Did you commit the changes for it?

Apologies @Jon. The changes have been committed and pushed

Hey @Batman,

Your node appears to be working fine for me.

Are you sure the API key you are using is correct?

hey @Jon which API key are you using. Are you generating it via the NASA API?
Are you changing the api under the
authenticate = {
type: ‘generic’,
properties: {
qs: {
‘api_key’: ‘={{$credentials.apiKey}}’
}
},
} as IAuthenticateGeneric;

in NasaPicsApi.credentials.ts

I guess I am making some silly error as I am new to n8n.

Hey @Batman,

I am getting a key from Nasa then inputting it into the credential in the n8n UI.

hey @Jon . As I said I am not even getting the NASA Pics node option anymore for some reason.

I am running the same commands in the terminal as before, however:

npm run build
npm link
npm link n8n-nodes-nasapics
n8n start

Hey @Batman,

Are you running the second npm link command in the ~/.n8n/nodes folder?

hey @Jon . sorry for the inconvenience, but this is what I am doing. It worked before so I do not know what is going wrong now

You need to run npm run link n8n-nodes-nasapics in the n8n nodes folder which is normally ~/.n8n/nodes

I have done that too


Can you send the commands you used in your terminal. Since you pulled my code the folders must be the same. Appreciate the help

Hey @Batman,

You are still not using the correct nodes folder that is why it is not working. You need to use ~/.n8n/nodes the full path for that would be something like /Users/aaditroychowdhury/.n8n/nodes so the commands would be…

npm install
npm link
cd ~/.n8n/nodes
npm link n8n-nodes-nasapics
n8n start

If ~/.n8n/nodes shows an error run mkdir ~/.n8n/nodes then the cd command.