we are using n8n to transfer shipment data form our ERP to the logistics company.
Unfortunately, special characters like ß, ü, ö and so on are not transferred to the logistics company as they need the POST request to be in ISO-8859-1.
Sure,
n8n version: 1.32.2
Database: unchanged, so I guess SQLite
n8n EXECUTIONS_PROCESS setting: default
Running in Docker on Synology NAS
OS: Synology
Unfortunately I can hardly share the flow as it holds some sensitive data. (not only credentials but also one specific API is not open to the public)
We use the HTTP node to get data from json in previous nodes and then post it to the API:
Unfortunately some of the nodes (like the http) directly hold sensitive data.
We try to use the following code to change the encoding, whichs works with then using “Convert to File” (with the correct encoding selected) and after that “Read/Write files from disk”.
function encodeToISO88591(str) {
return Buffer.from(str, ‘utf8’).toString(‘binary’);
}
function encodeObject(obj) {
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
if (typeof obj[key] === ‘string’) {
obj[key] = encodeToISO88591(obj[key]);
} else if (typeof obj[key] === ‘object’ && obj[key] !== null) {
obj[key] = encodeObject(obj[key]);
}
}
}
return obj;
}
// Get the input data
const inputData = items.map(item => item.json);
// Encode all values in the input data
const encodedData = inputData.map(data => encodeObject(data));
// Return the encoded data
return encodedData.map(data => ({ json: data }));
Using the following headers in the http node does not work unfortunately:
We improved our handling of ISO-8859-1 responses 4 days ago. Once this fix is out on Wednesday, can you please try to upgrade, and also set the Content-Type to include charset=latin1 on your requests we well?
We might still need to update a few other nodes to make them all respect the response encoding. So if this is about a specific node, please let us know, and we’ll try to prioritize updating that node’s response handling.