Hi,
I am trying to update app_metadata called ‘credit_left’ by a post request to this API:
app.post(‘/app-metadata-credit-left’, async (req, res) => {
var metadata = {
credit_left: 10
};
management.updateAppMetadata(req.body.sub, metadata, (err, user) => {
if (err) {
console.log(err);
} else {
console.log(`Successfully updated app metadata for user with ID ${req.body.sub}`);
}
});
res.json({ app_metadata: metadata })
});
I keep getting a “Not Found: Not Found” error, please help.
Thanks
Hi @erfan.saraj ,
I understand you want to update the user app_metadata.credit_left attribute via the post request. The endpoint for updating the app_metadata requires the user_id. If the info is missing in the function, it will return the not found error.
Here is what the sample scripts look like:
var params = { id: USER_ID };
var metadata = {
foo: 'bar'
};
management.updateAppMetadata(params, metadata, function (err, user) {
if (err) {
// Handle error.
}
// Updated user.
console.log(user);
});
You may find the details in this doc.
Please let me know if any further queries about this topic. Thanks!