Create Rule via Api

Hi There,

I am trying to create rule via the management API. I am getting the error {“statusCode”:400,“error”:“Bad Request”,“message”:“Payload validation error: ‘Additional properties not allowed: id’.”,“errorCode”:“invalid_body”}`

here is the code which m using

const ruleScript = “function (user, context, callback) {\n callback(null, user, context);\n}”;
const ruleName = Auth Server Update;
const rules: Rule = [{ name: ruleName, enabled: true, id: ‘newrule’, order: 1, script: ruleScript, stage: ‘login_success’ }];

management.createRule(rules[0], (err: Error, rule) => {
console.log(err, rule);
});

Any help would be really appreciated.
Thanks

Hi @akshay.verma

When creating the rule you are unable to specify the id as this is an auto-generated field.

The only fields you may specify when creating a rule are: name, script, order, and enabled.

Hope this helps!

2 Likes

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