Get collection of Projects

👍

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/projects?include=[Id,Name,UserStories]&take=100&innertake=1000
  • /api/v1/userstories?include=[Id,Name,Project]&take=1000

We recommend using the second approach.

Here are some popular queries:
  • get Projects created last month:
    /api/v1/projects?where=(CreateDate gte '2017-01-01')and(CreateDate lte '2017-01-31')&take=1000

  • get Projects finished last months:
    /api/v1/projects?where=(EndDate gte '2017-01-01')and(EndDate lte '2017-01-31')&take=1000

  • get a list of members of Projects ID#13:
    /api/v1/projects/13/ProjectMembers?where=(User.IsActive eq 'true')include=[User]&take=1000
    or
    /api/v1/ProjectMembers?where=(project.id eq 13)and(User.IsActive eq 'true')&include=[User]&take=1000

  • get a list of Teams assigned to Project ID#13
    /api/v1/projects/13/TeamProjects?include=[Team]&take=1000
    or
    /api/v1/TeamProjects?where=(project.id eq 13)&include=[Team]&take=1000

  • get a list of Milestones for Project ID#2
    /api/v1/projects/2/Milestones?take=1000

  • show a list of available practices for Project ID#2
    /api/v1/projects/2?include=[Process[Practices]]

  • get Projects created by user ID#1:
    /api/v1/projects?where=(Owner.Id eq 1)&include=[Id,Name,CreateDate,StartDate,EndDate,EntityState]&take=1000

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;

            //get 3 oldest Projects which are not finished yet
            string query = "projects?where=(EntityState.IsFinal eq 'false')&take=3&orderby=CreateDate&include=[Id,Name,EntityState]";

            //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;

            //get Projects finised last week
            string lastMonday = DateTime.Now.AddDays(-(int)DateTime.Now.DayOfWeek - 6).ToString("yyyy-MM-dd");
            string query = "projects?where=(EndDate gte '" + lastMonday + "')&include=[Id,Name,EndDate]&take=1000";

            //using access token generated at Personal Details page (Access Tokens tab)
            query += "&access_token=MTpoUmx4WW1LTzF6dlkvbUN1dTZIclVBUFQyQ1Z0MkN6YnF6OHBETmRZN2kwPQ==";
            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;

            //get Users assigned to Project with ID#2
            string query = "projects/2/ProjectMembers?where=(User.IsActive eq 'true')include=[User]&take=1000";

            //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;

            //get a Project with ID#13
            string query = "projects/206?include=[Id,Name,EntityState]&append=[UserStories-count]";

            //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!