Preventing duplicate departments when adding users via the API
Who is this article for?
Administrators or Developers using the Q-Pulse Web Service API to create or update users.
API access and permissions to use the Core.svc endpoint are required.
This article addresses an issue where using the API to add or update users can create duplicate or malformed entries in the 'Department' managed list.
1. Issue
To add or update a user via the Core Service API, use the Upsert Person method, which includes a field for the user's department:
- <v1:DepartmentPath>Dev/Tech</v1:DepartmentPath>
While the Active Directory import auto-adds new departments, the API docs don't confirm this for Upsert Person.
As per support ticket #1244490, if the DepartmentPath doesn't exactly match an existing department, it may create malformed or duplicate entries, causing difficult-to-fix "bad data" since Q-Pulse lacks bulk edit or deletion options for departments and archived accounts.
2. Solution
To avoid creating incorrect department data, validate the department path before calling the Upsert Person method.
2.1. Retrieve the valid department list
Use the Core.svc GetManagedList method to get all valid departments. Set the <v1:type> parameter to Department.
Sample request:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://www.qpulse.com/QPulseWebServices/v1.2/">
<s:Header/>
<s:Body>
<v1:GetManagedList>
<v1:token>YOUR-AUTHORISATION-TOKEN</v1:token>
<v1:type>Department</v1:type>
</v1:GetManagedList>
</s:Body>
</s:Envelope>2.2. Validate the department path
Before calling Upsert Person, check if your department string matches a FullPath from the GetManagedList response:
- If it matches exactly, proceed.
- If it does not match, handle the error (e.g., log, skip, or assign a default department).
2.3. Add or update the user
With a validated DepartmentPath, safely call Upsert Person to avoid malformed entries.
Sample Request:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://www.qpulse.com/QPulseWebServices/v1.2/">
<s:Header/>
<s:Body>
<v1:UpsertPerson>
<v1:token>YOUR-AUTHORISATION-TOKEN</v1:token>
<v1:personData>
<v1:ID>1</v1:ID>
<v1:FirstName>Joe</v1:FirstName>
<v1:LastName>Bloggs</v1:LastName>
<v1:EMailAddress>j@localhost</v1:EMailAddress>
<v1:IsUser>true</v1:IsUser>
<!-- Validated against GetManagedList response -->
<v1:DepartmentPath>Dev/Tech</v1:DepartmentPath>
</v1:personData>
</v1:UpsertPerson>
</s:Body>
</s:Envelope>Status on bulk editing
If duplicate departments exist, note there is no bulk tool to fix them yet. An enhancement request (IQMPRO-I-1058) is in progress.