- Joined
- Dec 30, 2021
- Messages
- 68
- Reaction score
- 15
Hi everyone,
I'm trying to create users in 3CX via the API using cURL. The user gets created successfully, but I noticed that it is created without any department assigned.
Here’s the command I’m using:
I’ve attached a screenshot showing the user created without a department.
Questions:
Thanks in advance!
I'm trying to create users in 3CX via the API using cURL. The user gets created successfully, but I noticed that it is created without any department assigned.
Here’s the command I’m using:
Code:
TOKEN=$(curl -sk -X POST "https://3cx.domain.tld:5001/connect/token" -H "Content-Type: application/x-www-form-urlencoded" -d "client_id=MYCLIENTID&client_secret=MYCLIENTSECRET&grant_type=client_credentials" | jq -r .access_token)
curl -sk -X POST "https://3cx.domain.tld:5001/xapi/v1/Users" -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d @- <<EOF
{
"Number": "$NUMBER",
"Enable2FA": false,
"Require2FA": false,
"MyPhoneShowRecordings": true,
"MyPhoneAllowDeleteRecordings": false,
"MyPhoneHideForwardings": false,
"MyPhonePush": true,
"RecordCalls": true,
"AllowOwnRecordings": true,
"RecordExternalCallsOnly": true,
"RecordEmailNotify": false,
"FirstName": "$FIRST_NAME",
"LastName": "$LAST_NAME",
"DisplayName": "$FIRST_NAME $LAST_NAME",
"EmailAddress": "$EMAIL",
"Mobile": "$MOBILE",
"WebMeetingFriendlyName": "$SAMACCOUNTIDWITHOUTDOT",
"VMEmailOptions": "None",
"VMPIN": "$NUMBER",
"Language": "en",
"SendEmailMissedCalls": false
}
EOF
I’ve attached a screenshot showing the user created without a department.
Questions:
- How can I assign a department (PrimaryGroupId) when creating a user via the API? When i'm adding PrimaryGroupId paramenter i get this error
Code:
{"error":{"code":"","message":"PrimaryGroupId:\nWARNINGS.XAPI.NOT_FOUND","details":[{"code":"","message":"WARNINGS.XAPI.NOT_FOUND","target":"PrimaryGroupId"}]}} - What is the correct method to delete a user or at least disable it via the API? I tried using DELETE /Users/{id} but it didn’t work, and also Pbx.BatchDelete returned an error.
Thanks in advance!