I have a requirement to import users to auth0. To achieve this I am using auth0's bulk user import API which accepts JSON file as input.
In my lambda, I have a JSON object with all the users list. I am able to write this data to a file and send to auth0 which works just fine but
Is there a way I can directly send this JSON object as a file?
This is the working code for me -
const options = {
uri: `${auth0Url}/api/v2/jobs/users-imports`,
method: 'POST',
headers: {
Authorization: `Bearer ${this.token}`,
},
formData: {
users: fs.createReadStream('/home/tushar/Documents/codes/auth-svc/test.json'),
connection_id: 'auth0 connection id',
upsert: 'false',
};
rp(options)
.then((body) => {
console.log('Success-', body);
})
.catch((err) => {
console.log('-Error-', err);
});
Is it possible to send without writing and sending a file?