Get collection of Users

👍

More information

📘

Options for working with inner collections

If you'd like to get an inner collection there is an option to either include it into the list of retrieved fields, or to query this collection directly:

  • /api/v1/users?include=[FirstName,LastName,Comments[CreateDate,Description]]&take=100&innertake=1000
  • /api/v1/users?where=(Owner.Kind eq 'User')&include=[CreateDate,Description,Owner[FirstName,LastName]]&take=1000

We recommend using the second approach.

Here are some popular queries:
  • get deleted users
    /api/v1/users?where=(DeleteDate is not null)&take=1000

  • get active users
    /api/v1/users?where=(DeleteDate is null)and(IsActive eq 'true')&take=1000

  • get User created last months:
    /api/v1/users?where=(CreateDate gte '2017-01-01')and(CreateDate lte '2017-01-31')&take=1000

  • get current user:
    /api/v1/users/loggeduser

  • find a User by email:
    /api/v1/users?where=(email eq '[email protected]')

  • get Users who didn't log in into Targetprocess since 31 December 2016
    /api/v1/users?where=(LastLoginDate lte '2016-12-31')&include=[Email,IsActive,LastLoginDate]

  • get Users who has never logged in into Targetprocess
    /api/v1/users?where=(LastLoginDate is null)&include=[Email,IsActive]

using System;
using System.Net;
using System.Net.Http;

namespace REST.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri("https://restapi.tpondemand.com/api/v1/");
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

            //find a User by email
            string query = "users?where=(email eq '[email protected]')";

            //using a token generated at /api/v1/Authentication
            query += "&token=Njo4OTIyQzkzN0M5NEY3NzNENDIyNTM2RDU3MTMwMTMwOA==";
            Console.WriteLine("Pulling " + query);
            
            HttpResponseMessage response = client.GetAsync(query).Result;
            if (response.IsSuccessStatusCode)
            {
                Console.WriteLine(response.Content.ReadAsStringAsync().Result);
            }
            else
            {
                Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
            }
        }
    }
}
using System;
using System.Net;
using System.Net.Http;

namespace REST.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri("https://restapi.tpondemand.com/api/v1/");
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

            //find a User by email
            string query = "users?where=(email eq '[email protected]')";

            //using access token generated at Personal Details page (Access Tokens tab)
            query += "&access_token=NjplaXdQeTJDOHVITFBta0QyME85QlhEOWpwTGdPM2V6VjIyelZlZ0NKWG1RPQ==";
            Console.WriteLine("Pulling " + query);

            HttpResponseMessage response = client.GetAsync(query).Result;
            if (response.IsSuccessStatusCode)
            {
                Console.WriteLine(response.Content.ReadAsStringAsync().Result);
            }
            else
            {
                Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
            }
        }
    }
}
using System;
using System.Net;
using System.Net.Http;
using System.Text;

namespace REST.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri("https://restapi.tpondemand.com/api/v1/");
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

            //find a User by email
            string query = "users?where=(email eq '[email protected]')";

            //using basic authentication (here 'John' is login and '123' is password)
            string authentication = Convert.ToBase64String(Encoding.ASCII.GetBytes("John:123"));
            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", authentication);
            Console.WriteLine("Pulling " + query);

            HttpResponseMessage response = client.GetAsync(query).Result;
            if (response.IsSuccessStatusCode)
            {
                Console.WriteLine(response.Content.ReadAsStringAsync().Result);
            }
            else
            {
                Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
            }
        }
    }
}
using System;
using System.Net;
using System.Net.Http;

namespace REST.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri("https://restapi.tpondemand.com/api/v1/");
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

            //find a User by email
            string query = "users?where=(email eq '[email protected]')";

            //using no authentication will result in 401 Unauthorized response
            Console.WriteLine("Pulling " + query);

            HttpResponseMessage response = client.GetAsync(query).Result;
            if (response.IsSuccessStatusCode)
            {
                Console.WriteLine(response.Content.ReadAsStringAsync().Result);
            }
            else
            {
                Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
            }
        }
    }
}
Language
Click Try It! to start a request and see the response here!