Above is the error message I got when trying to use an API key I generated in n8n to use Cursor for deployment. I’ve also had several 401 errors stating that I didn’t have permissions. This is on a self hosted iteration that is running n8n version 1.102.3. Any help with sorting permissions would be greatly appreciated as neither myself nor the owner can figure it out.
Hey @Kumi_Kemp hope all is well and welcome to the community.
Using angle brackets (<...>
) around the token is incorrect unless they are part of the actual token - which they almost certainly are not. Try without it.
I got exactly the same error message back. Thank you for the advice though!
Thanks for confirming, could you try curl.exe
instead of just curl
?
This time it returned this error message: {“status”:“error”,“message”:“Unauthorized”}
Ok, now this is progress.
The reason for the previous error was that curl is just an alias for Invoke-WebRequest, where the parameters you passed are not recognized by the Invoke-WebRequest. curl.exe on the other hand is an actual curl binary.
As for the error - now you just need to work on getting the bearer token right
Could you show the output of running it as curl.txt?
try pasting again, the post was hidden for some reason
Keeps hiding it for some reason. In short curl.exe is outputting this error message: {“status”:“error”,“message”:“Unauthorized”} and curl.txt is outputting this one: curl.txt : The term ‘curl.txt’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
- curl.txt -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVC …
-
+ CategoryInfo : ObjectNotFound: (curl.txt:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Ahaha, sorry I absolutely did not mean to write curl.txt
, it was a typo
As for the curl.exe
, yes, looks like it was sent to the server correctly, it is just not liking your credentials.
No worries. Could it be something to do with the self hosting? I’m just a member and we can’t figure out how to get it to work. Have you got any further suggestions?
I should have probably started with that, but … what is it you are trying to do to begin with?
I’m trying to use Cursor to generate a template for workflows and have it import them into n8n for me where I can then test them
Are you following this API reference?
I wasn’t but it seems I have unintentionally followed it anyway. I’m getting a 401 error every time anyway
API endpoint for creating a workflow is:
/api/v1/workflow
This is how the API call request would look like to create a workflow:
The API endpoint is different, also the key is passed differently.
I don’t recognise that screen. Where did you get to that and how can I use it?
This screen is just an example of how the request would look like going to the API endpoint for creating a workflow from JSON. This is not from n8n, but rather from an intercepting proxy. This was just to illustrate the different in API endpoint I was using to create the workflow.
Okay. So what would you recommend I do now then?
Try this (change YOUR_API_KEY with yours):
in bash:
curl https://agents.aipotential.ai/api/v1/workflows \
-H "Content-Type: application/json" \
-H "X-N8N-API-KEY: <YOUR_API_KEY>" \
-d '{"name":"My workflow 123","nodes":[{"parameters":{},"type":"n8n-nodes-base.manualTrigger","typeVersion":1,"position":[0,0],"id":"0b455e46-9260-4df0-81aa-d693e3195ecb","name":"When clicking \u2018Execute workflow\u2019"}],"settings":{},"connections":{"When clicking \u2018Execute workflow\u2019":{"main":[[]]}},"staticData":null}'
in powershell:
curl https://agents.aipotential.ai/api/v1/workflows `
-H "Content-Type: application/json" `
-H "X-N8N-API-KEY: <YOUR_API_KEY>" `
-d '{"name":"My workflow 123","nodes":[{"parameters":{},"type":"n8n-nodes-base.manualTrigger","typeVersion":1,"position":[0,0],"id":"0b455e46-9260-4df0-81aa-d693e3195ecb","name":"When clicking \u2018Execute workflow\u2019"}],"settings":{},"connections":{"When clicking \u2018Execute workflow\u2019":{"main":[[]]}},"staticData":null}'