HTTP Request node Returns 401 Unauthorized -Invalid API Key

Hi everyone , i am having an issue with the HTTP request node in n8n . the request executes , but i keep getting: "Request failed with status code 401 (unauthourized) - {“message”: “Invalid API Key”}

i have also checked the url and request parameters, but the API still rejects the request . what is the correct way to configure the api key in the HTTP Request node

Hey @Emmanue22, while you wait for a response, here are some things that might help:

Suggested resources

Automatically matched to your question.

Docs:

Forum:

@Michael_Long, @withabdul - you’ve helped with similar issues before, can you take a look?

Automatically suggested by n8n’s community bot. It’s a pilot - please share feedback here.

Hi @Emmanue22 Welcome!
Authentication is set to None in that node and the only header on the request is Accept, so no key is leaving n8n at all and the API is rejecting an anonymous call.
Set Authentication to Generic Credential Type and pick Header Auth, then create a credential with the header name and value your API documents, commonly x-api-key, or Authorization holding Bearer <token>. If your API expects the key as a query parameter rather than a header, Query Auth does the same job for a parameter.

i still don’t get it , please

@Emmanue22
Hi , it is just a 401 response which usually means the API key is missing , incorrect , or being sent in the wrong format.

in the HTTP Request node, open authtenticatio0n and select method required by the api, or use headders if the api expects a custom header ,
secondly add the api key using the header format specified by the api document .for example

name : Autthorization
value: Bearer “You api key”

also make sure you don’t include Bearer if the api document specifically expects only the raw key
also verify the credentials
and execute again

this looks like an ai generated answer not real human and i have also used ai but it is not working

ok i would try

ok and please show the output when you are done

@Emmanue22 Here it is as clicks.

  1. Click the Authentication dropdown that currently reads None and pick Generic Credential Type.
  2. A second dropdown called Generic Auth Type appears. Pick Bearer Auth if your API wants Authorization: Bearer <key>, or Header Auth if it wants its own header such as X-API-Key.
  3. Click Create new credential. Bearer Auth has one field for the token, so paste the key with no Bearer typed in front of it. Header Auth has two, the header name in Name and the key in Value.
  4. Save the credential, then run the node again.

ahhh!!! thank you !!

No he is just very fast :sweat_smile: ..lol .. He is human , you are welcome

@n8n @bartv @Anshul_Namdev , please can anyone tell me what i did wrong for thes system to flag my post , yes i used Ai for my knowledge base , but i did not wirte those with Ai