How to find the department id, siteid which can be used while adding users via API

How to find the department id, siteid which can be used while adding users via API

Query to find the deptid:

* In order to add a user under the correct department/site, the departmentid is required. The department id can be found using the below query. 

* In the application UI, go to Reports - > New query report, and execute the below query. This will show the site details and the department id. 

Select distinct adef.org_name "Account Name", asite.siteid, pdep.deptid, pdep.ciid, ddef.deptname from accountdefinition adef LEFT JOIN portalaccounts pac ON adef.org_id=pac.accountid left join 
accountci ac  on pac.ciid=ac.ciid left join accountsitemapping asite on adef.org_id=asite.accountid left join departmentdefinition ddef on asite.siteid=ddef.siteid  left join portaldepartments pdep on ddef.deptid=pdep.deptid

where adef.org_name like '%AccountName%' and ddef.deptname like '%DepartmentName%';


- > In the above filter, you shall mention the Account name and department name if you would want to know the departmentid for a specific department under which the user ought to be added. 


Adding user via API:

Now, that the department id is known, the user shall be added via API under the given department. 

Sample API Json Input:

{
    "user": {
        "first_name": "Abdullah",
        "last_name": "M",
        "name": "Abdullah M",
        "is_vipuser": "false",
        "department": {
            "id": "1"
        },
        "mobile": "02892902",
        "description": "Help Desk manager",
        "sms_mail_id": "abdullah@zoho.com",
        "jobtitle": "Java developer",
        "phone": "929992",
        "email_id": "abdullah@zoho.com",
        "secondary_emailids": [
            "Ab@zohocorp.com",
            "Ab2@zohocorp.com",
            "Ab3@zoho.com"
        ]
        }
    }



                  New to ADSelfService Plus?

                    • Related Articles

                    • Adding attachment to Resolution using API

                      PURPOSE: To add an attachment to the resolution via API. STEPS: 1) Upload the attachment file and obtain the attachment ID: URL: <domain_url>/api/v3/requests/upload Method: POST Payload: files ( input_data = <file_content> ) Response: 2) Add the ...
                    • Department head details

                      This report is used to get the complete list of Department and the department head configured in the application SELECT dept.deptid "Department ID", dept.deptname "Department Name", dept.phoneno "Phone No", dept.fax "Fax", sdorg.name "Site Name", ...
                    • Query to get the user details (both technicians and requesters) account-wise with User ID (MSSQL & PGSQL)

                      Tested in builds PGSQL (14300) or MSSQL (14306) Tested in builds : 14000, 14201, 14301 1) Query to get the First Name, Last Name, Display Name, Login User ID, Login Name, Email and Phone Number of all users in the application, account-wise, with the ...
                    • Query to find users under blocked state

                      select * from sduser sd left join CI ci on sd.ciid=ci.ciid left join AaaUserContactInfo auc on sd.userid=auc.user_id left join AaaContactInfo aci on auc.contactinfo_id=aci.contactinfo_id where sd.status='blocked'
                    • 10.5 API - How APIs can be used in the version 10.5 and above ?

                      Introduction: REST API acts as a bridge between ServiceDesk Plus MSP and other applications. The communication of information happens via HTTP Request. The REST API authenticates users using Technician Key, thus eliminating the need for the users to ...