[Bug Report] The httpCustomAuth credential crashes when updated via API

Describe the problem/error/question

When updating a Custom Auth credential using the PATCH method via API. When you visit the credential in UI it shows that it was updated “Just now”, but doesn’t have the JSON box anymore (see picture).

What is the error message (if any)?

Please share your workflow

Information on your n8n setup

It’s a data type mismatch. The json field in the Custom Auth credential expects a String (text) that contains JSON, but you are sending a raw JSON Object. The API saves the object successfully, but the UI text editor breaks because it tries to load an object instead of a string.

To fix it, you need to stringify the content of the json field.
In your HTTP Request node body, change it to use an expression like this:
{
“data”: {
“json”: {{ JSON.stringify({
“body”: {
“client_id”: “1”,
“client_secret”: “2”
}
}) }}
}
}

This didn’t make any difference. This updates the custom credential (which already was the case), but in the credential itself (in the UI) it doesn’t show the JSON block and the credential also doesn’t work (so it isn’t correctly updated).

To test whether it was correctly updated I used a Github pat. The JSON Body I used:

{
“data”: {
“json”: {{
JSON.stringify({
“headers”: {
“Authorization”: “Bearer <GITHUB_PAT>”
}
})
}}
}
}

And btw the schema for the Custom Auth Credential DOES require a json object:

{
“type”: “object”,
“additionalProperties”: false,
“properties”: {
“json”: {
“type”: “json”
}
},
“required”: [“json”]
}

SOLUTION:

Double stringify the json, so that it also contains the needed escape characters. Example:

{
“data”: {
“json”: {{
JSON.stringify(JSON.stringify(
{
“body”: {
“solution”: “found”
}
}
))
}}
}
}

1 Like

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