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?

        Resources

            • Related Articles

            • 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 ...
            • Allowance, used and remaining Hours

              Go to Reports Tab >> New Query Reports >> Run the below query Databases : PGSQL & MSSQL: select ad.org_name "Account",sp.serviceplanname "Service Plan",longtodate(ac.startdate) "Contract Start Date", longtodate(ac.expirydate) "Contract Expiry Date", ...
            • Query to pull Account ID and Site ID

              Go to Reports Tab >> New Query Report and run the below query.  For Postgres & MS SQL select adef.org_id "Account ID", adef.org_name "account",sdef.siteid "Siteid", sdo.name "Site" from sitedefinition sdef left join accountsitemapping asm on ...
            • Last Login Report - All Users

              SELECT AaaUser.FIRST_NAME "Users", MAX(AaaLogin.NAME) "LoginName", MAX(AaaContactInfo.EMAILID) "Email", MAX(AaaAccSession.USER_HOST) "IP Address", longtodate(MAX(AaaAccSession.OPENTIME)) "Logged In Time" , longtodate(MAX(AaaAccSession.CLOSETIME)) ...
            • CMDB API - Add CI along with users name

              <?xml version="1.0" encoding="UTF-8"?> <API version="1.0" locale="en">     <records>         <record>             <parameter>                 <name>CI Name</name>                 <value>saharsh</value>             </parameter>             <parameter> ...