It is your script basically:
const url = 'https://localhost:5001/identity-server/connect/token';
const headers = {
'Content-Type': 'application/x-www-form-urlencoded'
};
const body = {
grant_type: 'client_credentials',
client_id: 'test2:default',
client_secret: 'haaspncugudtjudzwd9mfgyi8mfkvq8qxxxxc7kxqf8x',
scope: 'squidex-api'};
postJSON(url, body, (data) => {
throw `Duplicate reference detected: ${JSON.stringify(data)} cooking instruction with SKU already exist.`;
}, headers);
I have only replaced the values.