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
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.
@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
Click the Authentication dropdown that currently reads None and pick Generic Credential Type.
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.
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.
@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