[DONE] tape.User.create() fails with 500

Hi, I’m trying to invite users to a workspace as member using tape.User.create().
The API Key I’m using is from a Workspace Admin.
Am I doing something wrong or is it broken?

tape.setApiKey('user_key_ey***v73BJXT3DnTY')
const name = member_field_name_value;
const email = member_field_email_email;
const role = 'member';
const data = {
    name: name,
    email: email,
    role: role
}
console.log('data', JSON.stringify(data));

try {
    await tape.User.create(
        JSON.stringify(data)
    )
} catch (e) {
    console.log('error', JSON.stringify(e));
}
[07:23:13.013] Action execution started.
[07:23:13.013] data, {"name":"Roger Sterling","email":"info@***.**","role":"member"}
[07:23:13.048] error, {"responseBody":{"status_code":500,"endpoint":"/v1/org/user","error_code":"unknown","error_message":"An unknown exception occurred"},"httpStatusCode":500}
[07:23:13.048] Action execution succeeded.

Hi @Kollaborateur I have an internet change over day today so trick for me to check but if you change your first line to:

await tape.setApiKey('user_key_ey***v73BJXT3DnTY')

does it work?

1 Like

Thanks @Jason, no there is no change.

{"responseBody":{"status_code":500,"endpoint":"/v1/org/user","error_code":"unknown","error_message":"An unknown exception occurred"},"httpStatusCode":500}

okay this works for me:

await tape.setApiKey('user_key_ey')

await tape.User.create({
    name:'test-jason',
    email:'jaosn@',
    role: "member"
})

try calling your data variable as something different i think it is making the call look like:

await tape.setApiKey('user_key_ey')

await tape.User.create(
data:{
    name:'test-jason',
    email:'jaosn@',
    role: "member"
})

which doesn’t work in this instance

2 Likes

It has to be an object, not stringified as stated in the API doc.

curl -X POST https://api.tapeapp.com/v1/org/user \
  -u user_key_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiLvv73vv73vv71cdTAwMDfvv71qXHUwMDA177-977-977-9Iiwic2NvcGUiOiJ1a192MSJ9.gpEuOArMgJ-t45rlXiLLz8-rHqTmCeU7oiMxymnsjhs: \
  -H "Content-Type: application/json" \
  --data '{
    "name": "Roger Sterling",
    "email": "rsterling-sc@me.com",
    "role": "admin",
    "skip_invitation": true
  }' 

So this works for me as well now:

let data = {
    name: name,
    email: email,
    role: role
};
await tape.User.create(data);

Thanks Jason!

1 Like