Hi @shakthipsg!
Your body is sending data as a plain string (the token value directly), but the API expects data to be a JSON object with the appropriate credential fields, not a raw string value.
The PATCH /credentials/{id} endpoint expects this structure: [API Docs]
Hi @shakthipsg Actually we do have a documentation but it is not quite aware of common errors and more problems:
And consider using this structure because the issue currently is with body and how you are structuring it consider trying this:
$body = @{
data = @{
accessToken = $tokenResponse.Token # use the actual field name for your credential type
}
isPartialData = $true # merges with existing data instead of replacing everything
} | ConvertTo-Json -Depth 5
Invoke-RestMethod `
-Method PATCH `
-Uri "$n8nUrl/api/v1/credentials/$credentialId" `
-Headers @{
"X-N8N-API-KEY" = $apiKey
"Content-Type" = "application/json"
} `
-Body $body