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?