Open this page in the API Guide

POST /Account/Count/

Gets the number of accounts that match the filter.
 

Request

Method Request URI
post /API/Account/Count/?sessionId=value

URI Parameters

URI Parameter Description
sessionId Current session ID. Specifying via an Authorization request header instead is recommended.

Request Headers

Authorization: Bearer <Current session ID>

Request Body

Name: options
Type: Dundas.BI.WebApi.Models.GetAccountsOptions

Response

Response Body

An integer representing the number of accounts that match the filter criteria.

Response Codes

Response Code Description
200 The operation completed successfully.
400 The request contained one or more invalid parameters.
440 The caller is not associated with a valid session.

Examples

This example will the query the number of accounts that match the filter for "dundas".

C# Java JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using System.Net;
using System.Net.Http;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Web.Script.Serialization;
 
   ...
 
using (HttpClient httpClient = new HttpClient())
{
    // Get Session Id
    string logonUri = "http://localhost:8004/Api/LogOn/";
    var logonOptions = new
    {
        accountName = "admin",
        password = "1234",
        cultureName = string.Empty,
        deleteOtherSessions = true,
        isWindowsLogOn = false
    };
 
    JavaScriptSerializer serializer = new JavaScriptSerializer();
    var requestBodyAsString = serializer.Serialize(logonOptions);
    StringContent content =
        new StringContent(
            requestBodyAsString,
            Encoding.UTF8,
            "application/json"
        );
 
    string jsonString = string.Empty;
 
    using (var response = httpClient.PostAsync(logonUri, content).Result)
    {
        jsonString =
            response.Content.ReadAsStringAsync().Result;
    }
 
    var obj = (Dictionary<string,object>) serializer.DeserializeObject(jsonString);
    string sessionId = obj["sessionId"].ToString();
 
    // Add an Authorization header
    httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", sessionId);
 
    // Define the request body
    HttpContent requestBody = null;
    requestBody =
        new StringContent(@"
        {
            ""queryAccountsOptions"": {
                ""pageNumber"": 1,
                ""pageSize"": 25,
                ""filter"": [
                    {
                        ""field"": ""AccountType"",
                        ""operator"": ""Equals"",
                        ""value"": ""VirtualWindowsUser"",
                        ""options"": ""InvertOperator""
                    },
                    {
                        ""field"": ""None"",
                        ""operator"": ""Or"",
                        ""value"": [
                            {
                                ""field"": ""Name"",
                                ""operator"": ""Contains"",
                                ""value"": ""dundas"",
                                ""options"": ""None""
                            },
                            {
                                ""field"": ""DisplayName"",
                                ""operator"": ""Contains"",
                                ""value"": ""dundas"",
                                ""options"": ""None""
                            }
                        ],
                        ""options"": ""None""
                    }
                ]
            }
        }
        ",Encoding.UTF8,"application/json");
    using (var response = httpClient.PostAsync(url, requestBody).Result)
    {
        if(response.StatusCode == HttpStatusCode.OK)
        {
            Console.WriteLine("Success");
 
            // An integer representing the number of
            // accounts that match the filter criteria.
            string jsonObject = response.Content.ReadAsStringAsync().Result;
        }
    }
}