Users

Work with personal User accounts in Targetprocess with REST API

Get users who have not logged in the past days

Active users who have logged in to Targetprocess at least once and did not logged in after specified date (in this example, 17 Jan 2018):

GET /api/v1/Users?where=(IsActive eq "true") and (LastLoginDate lt "2018-01-17")&take=1000

Active users who have never logged in to Targetprocess and accounts for these users were created before specified date (in this example, 17 Jan 2018):

GET /api/v1/Users?where=(IsActive eq "true") and (LastLoginDate eq "null") and (CreateDate lt "2018-01-17")&take=1000

Prerequisites: IDs of Users

Some of these examples contain IDs of the Users as parameters. When you modify User accounts you have to pass proper numeric ID of a chosen user in your POST calls. IDs can be obtained from the People views or from the system directly.

📘

Get IDs of Users

Use special GET call to API to obtain numeric IDs of Users from your system.

/api/v1/Users?include=[Id,FirstName,LastName,Login,Email,IsActive]&where=LastName contains "Smith"```

Prerequisites: IDs of Roles

Some of these examples contain IDs of the Roles as parameters. When you modify User accounts you have to pass proper numeric ID of a chosen role in your POST calls. IDs can be obtained from system settings.

📘

Get IDs of Roles

Use special GET call to API to obtain numeric IDs of Roles from your system.

GET /api/v1/Roles?include=[Id,Name]&take=1000

Deactivate Users

Multiple users:

POST /api/v1/Users/bulk?token=[your token]
[
  {
    "Id": 70,
    "IsActive": false
  },
  {
    "Id": 75,
    "IsActive": false
  }
]

Add Users to Project Members

Multiple users:

POST /api/v1/ProjectMembers/bulk?token=[your token]
[
  {
    "User": {"Id": 678},
    "Project": {"Id": 1234},
    "Role": {"Id": 5}
  },
  {
    "User": {"Id": 890},
    "Project": {"Id": 3456},
    "Role": {"Id": 9}
  }
]

Create User and add to Project Members

POST /api/v1/Users/?token=[your token]
{
  "FirstName": "John",
  "LastName": "Doe",
  "Email": "[email protected]",
  "Login": "jdoe",
  "Password": "123456",
  "IsActive": false,
  "ProjectMembers":{
    "Items": [
      {"Project":{"Id":1340},"Role":{"Id":12}}
    ]
  }
}