Hi there, i’m trying to use the management API, i’ve red the docs and tried to implemented the code samples.
var options = { method: 'POST',
url: 'https://<hidden>.auth0.com/api/v2/users',
headers:
{ 'content-type': 'application/json',
authorization: 'Bearer ' + body.access_token },
body:
{
email: 'jane.doe@example.com',
user_metadata: { hobby: 'surfing' },
app_metadata: { plan: 'full' } },
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
This sample from https://auth0.com/docs/metadata/apis#management-api
Response
{ statusCode: 400,
error: 'Bad Request',
message: 'Payload validation error: \'Missing required property: connection\'.',
errorCode: 'invalid_body' }
Ok i’m missing connection: 'Initial-Connection'
, as mentioned here https://auth0.com/docs/api/management/v2#!/Users/post_users
So modified request:
var options = { method: 'POST',
url: 'https://<hidden>.auth0.com/api/v2/users',
headers:
{ 'content-type': 'application/json',
authorization: 'Bearer ' + body.access_token },
body:
{ connection: 'Initial-Connection',
email: 'jane.doe@example.com',
user_metadata: { hobby: 'surfing' },
app_metadata: { plan: 'full' } },
json: true };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
New Response
{ statusCode: 400,
error: 'Bad Request',
message: 'The connection does not exist.',
errorCode: 'inexistent_connection' }
Could somebody point me in the right direction.
Edit, also in the explorer API - same error