Trying to get n8n API to work

Same guy, just hit my posting limit because its a new account. This is the error message it gave me: Invoke-WebRequest : Cannot bind parameter ‘Headers’. Cannot convert the “Content-Type: application/json” value of type
“System.String” to type “System.Collections.IDictionary”.
At line:2 char:6

  • -H “Content-Type: application/json” `
  •  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidArgument: (:slight_smile: [Invoke-WebRequest], ParameterBindingException
    • FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Could this all be caused by me not having admin privileges? The part about permissions a little while back got me thinking about that.

Again, change curl to curl.exe.

Changed it now and I’m still getting errors: At line:3 char:1

  • -H "X-N8N-API-KEY: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIi …

The output stream for this command is already redirected.
At line:4 char:1

  • -d '{“name”:“My workflow 123”,“nodes”:[{“parameters”:{},“type”:" …

The output stream for this command is already redirected.
+ CategoryInfo : ParserError: (:slight_smile: , ParentContainsErrorRecordException
+ FullyQualifiedErrorId : StreamAlreadyRedirected

Oh god, only if I new anything about powershell or had one to try with…

You could try to do it with Invoke-WebRequest instead, I guess?.. Internet says the syntax is going to be something like

$headers = @{
  "Content-Type" = "application/json"
  "X-N8N-API-KEY" = "<YOUR_API_KEY>"
}

$body = '{
  "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
}'

Invoke-RestMethod -Uri "https://agents.aipotential.ai/api/v1/workflows" -Method POST -Headers $headers -Body $body
1 Like

No error this time:
name : My workflow 123
nodes : {@{parameters=; type=n8n-nodes-base.manualTrigger; typeVersion=1; position=System.Object;
id=0b455e46-9260-4df0-81aa-d693e3195ecb; name=When clicking ‘Execute workflow’}}
settings :
connections : @{When clicking ‘Execute workflow’=}
staticData :
active : False
versionId : b945b182-efdf-45d3-ac6b-dd267e702341
id : 9YY4Gwo7lfJE8KCq
meta :
pinData :
createdAt : 2025-07-22T17:43:27.947Z
updatedAt : 2025-07-22T17:43:27.947Z
isArchived : False
triggerCount : 0

Did it create the workflow in n8n? You should see the My Workflow 123 created there

It did! Thank you so much!

Great, so at least we know this is the correct endpoint and it works. Now you can either use Invoke WebRequest or try to figure out how to dance around curl in windows :slight_smile:

Glad we figured it out. If this was helpful, kindly switch back to the original posted and mark one of the answers (most helpful) as solution. Thank you.

Cheers.

Will do, thank you again!

1 Like

You are very welcome.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.