VB.NET UWP/WinRT Zendesk: List Users

Back to Index

List users, returning a maximum of 100 users per page.

Documentation: https://developer.zendesk.com/rest_api/docs/core/users#list-users

CURL Command

curl https://subdomain.zendesk.com/api/v2/users.json \
  -u zendesk_email/token:zendesk_api_token

VB.NET UWP/WinRT Example

Dim rest As New Chilkat.Rest
Dim success As Boolean

'  URL: https://subdomain.zendesk.com/api/v2/users.json
Dim bTls As Boolean = True
Dim port As Integer = 443
Dim bAutoReconnect As Boolean = True
success = Await rest.ConnectAsync("subdomain.zendesk.com",port,bTls,bAutoReconnect)
If (success <> True) Then
    Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason)
    Debug.WriteLine(rest.LastErrorText)
    Exit Sub
End If


rest.SetAuthBasic("zendesk_email/token","zendesk_api_token")


Dim sbResponseBody As New Chilkat.StringBuilder
success = Await rest.FullRequestNoBodySbAsync("GET","/api/v2/users.json",sbResponseBody)
If (success <> True) Then
    Debug.WriteLine(rest.LastErrorText)
    Exit Sub
End If

Dim respStatusCode As Integer = rest.ResponseStatusCode
If (respStatusCode >= 400) Then
    Debug.WriteLine("Response Status Code = " & respStatusCode)
    Debug.WriteLine("Response Header:")
    Debug.WriteLine(rest.ResponseHeader)
    Debug.WriteLine("Response Body:")
    Debug.WriteLine(sbResponseBody.GetAsString())
    Exit Sub
End If


Dim jsonResponse As New Chilkat.JsonObject
jsonResponse.LoadSb(sbResponseBody)

Dim next_page As String
Dim previous_page As String
Dim count As Integer
Dim i As Integer
Dim count_i As Integer
Dim id As Integer
Dim url As String
Dim name As String
Dim email As String
Dim created_at As String
Dim updated_at As String
Dim time_zone As String
Dim phone As String
Dim shared_phone_number As String
Dim photo As String
Dim locale_id As Integer
Dim locale As String
Dim organization_id As Integer
Dim role As String
Dim verified As Boolean
Dim external_id As String
Dim alias As String
Dim active As Boolean
Dim shared As Boolean
Dim shared_agent As Boolean
Dim last_login_at As String
Dim two_factor_auth_enabled As String
Dim signature As String
Dim details As String
Dim notes As String
Dim role_type As String
Dim custom_role_id As String
Dim moderator As Boolean
Dim ticket_restriction As String
Dim only_private_comments As Boolean
Dim restricted_agent As Boolean
Dim suspended As Boolean
Dim chat_only As Boolean
Dim default_group_id As Integer
Dim photoUrl As String
Dim photoId As Integer
Dim photoFile_name As String
Dim photoContent_url As String
Dim photoMapped_content_url As String
Dim photoContent_type As String
Dim photoSize As Integer
Dim photoWidth As Integer
Dim photoHeight As Integer
Dim photoInline As Boolean
Dim j As Integer
Dim count_j As Integer
Dim strVal As String
Dim file_name As String
Dim content_url As String
Dim mapped_content_url As String
Dim content_type As String
Dim size As Integer
Dim width As Integer
Dim height As Integer
Dim inline As Boolean

next_page = jsonResponse.StringOf("next_page")
previous_page = jsonResponse.StringOf("previous_page")
count = jsonResponse.IntOf("count")
i = 0
count_i = jsonResponse.SizeOfArray("users")
While i < count_i
    jsonResponse.I = i
    id = jsonResponse.IntOf("users[i].id")
    url = jsonResponse.StringOf("users[i].url")
    name = jsonResponse.StringOf("users[i].name")
    email = jsonResponse.StringOf("users[i].email")
    created_at = jsonResponse.StringOf("users[i].created_at")
    updated_at = jsonResponse.StringOf("users[i].updated_at")
    time_zone = jsonResponse.StringOf("users[i].time_zone")
    phone = jsonResponse.StringOf("users[i].phone")
    shared_phone_number = jsonResponse.StringOf("users[i].shared_phone_number")
    photo = jsonResponse.StringOf("users[i].photo")
    locale_id = jsonResponse.IntOf("users[i].locale_id")
    locale = jsonResponse.StringOf("users[i].locale")
    organization_id = jsonResponse.IntOf("users[i].organization_id")
    role = jsonResponse.StringOf("users[i].role")
    verified = jsonResponse.BoolOf("users[i].verified")
    external_id = jsonResponse.StringOf("users[i].external_id")
    alias = jsonResponse.StringOf("users[i].alias")
    active = jsonResponse.BoolOf("users[i].active")
    shared = jsonResponse.BoolOf("users[i].shared")
    shared_agent = jsonResponse.BoolOf("users[i].shared_agent")
    last_login_at = jsonResponse.StringOf("users[i].last_login_at")
    two_factor_auth_enabled = jsonResponse.StringOf("users[i].two_factor_auth_enabled")
    signature = jsonResponse.StringOf("users[i].signature")
    details = jsonResponse.StringOf("users[i].details")
    notes = jsonResponse.StringOf("users[i].notes")
    role_type = jsonResponse.StringOf("users[i].role_type")
    custom_role_id = jsonResponse.StringOf("users[i].custom_role_id")
    moderator = jsonResponse.BoolOf("users[i].moderator")
    ticket_restriction = jsonResponse.StringOf("users[i].ticket_restriction")
    only_private_comments = jsonResponse.BoolOf("users[i].only_private_comments")
    restricted_agent = jsonResponse.BoolOf("users[i].restricted_agent")
    suspended = jsonResponse.BoolOf("users[i].suspended")
    chat_only = jsonResponse.BoolOf("users[i].chat_only")
    default_group_id = jsonResponse.IntOf("users[i].default_group_id")
    photoUrl = jsonResponse.StringOf("users[i].photo.url")
    photoId = jsonResponse.IntOf("users[i].photo.id")
    photoFile_name = jsonResponse.StringOf("users[i].photo.file_name")
    photoContent_url = jsonResponse.StringOf("users[i].photo.content_url")
    photoMapped_content_url = jsonResponse.StringOf("users[i].photo.mapped_content_url")
    photoContent_type = jsonResponse.StringOf("users[i].photo.content_type")
    photoSize = jsonResponse.IntOf("users[i].photo.size")
    photoWidth = jsonResponse.IntOf("users[i].photo.width")
    photoHeight = jsonResponse.IntOf("users[i].photo.height")
    photoInline = jsonResponse.BoolOf("users[i].photo.inline")
    j = 0
    count_j = jsonResponse.SizeOfArray("users[i].tags")
    While j < count_j
        jsonResponse.J = j
        strVal = jsonResponse.StringOf("users[i].tags[j]")
        j = j + 1
    End While
    j = 0
    count_j = jsonResponse.SizeOfArray("users[i].photo.thumbnails")
    While j < count_j
        jsonResponse.J = j
        url = jsonResponse.StringOf("users[i].photo.thumbnails[j].url")
        id = jsonResponse.IntOf("users[i].photo.thumbnails[j].id")
        file_name = jsonResponse.StringOf("users[i].photo.thumbnails[j].file_name")
        content_url = jsonResponse.StringOf("users[i].photo.thumbnails[j].content_url")
        mapped_content_url = jsonResponse.StringOf("users[i].photo.thumbnails[j].mapped_content_url")
        content_type = jsonResponse.StringOf("users[i].photo.thumbnails[j].content_type")
        size = jsonResponse.IntOf("users[i].photo.thumbnails[j].size")
        width = jsonResponse.IntOf("users[i].photo.thumbnails[j].width")
        height = jsonResponse.IntOf("users[i].photo.thumbnails[j].height")
        inline = jsonResponse.BoolOf("users[i].photo.thumbnails[j].inline")
        j = j + 1
    End While
    i = i + 1
End While

Sample JSON Response Body

{
  "users": [
    {
      "id": 361801727573,
      "url": "https://chilkat.zendesk.com/api/v2/users/361801727573.json",
      "name": "Matt Fausey",
      "email": "admin@chilkatsoft.com",
      "created_at": "2018-04-14T19:01:56Z",
      "updated_at": "2018-04-14T23:09:24Z",
      "time_zone": "Bogota",
      "phone": null,
      "shared_phone_number": null,
      "photo": null,
      "locale_id": 1,
      "locale": "en-US",
      "organization_id": 360015071793,
      "role": "admin",
      "verified": true,
      "external_id": null,
      "tags": [
      ],
      "alias": null,
      "active": true,
      "shared": false,
      "shared_agent": false,
      "last_login_at": "2018-04-14T23:09:24Z",
      "two_factor_auth_enabled": null,
      "signature": null,
      "details": null,
      "notes": null,
      "role_type": null,
      "custom_role_id": null,
      "moderator": true,
      "ticket_restriction": null,
      "only_private_comments": false,
      "restricted_agent": false,
      "suspended": false,
      "chat_only": false,
      "default_group_id": 360000681553,
      "user_fields": {}
    },
    {
      "id": 361809055094,
      "url": "https://chilkat.zendesk.com/api/v2/users/361809055094.json",
      "name": "Sample customer",
      "email": "customer@example.com",
      "created_at": "2018-04-14T19:01:56Z",
      "updated_at": "2018-04-14T19:01:57Z",
      "time_zone": "Bogota",
      "phone": null,
      "shared_phone_number": null,
      "photo": {
        "url": "https://chilkat.zendesk.com/api/v2/attachments/360103279093.json",
        "id": 360103279093,
        "file_name": "profile_image_361809055094_2287229.jpg",
        "content_url": "https://chilkat.zendesk.com/system/photos/3601/0327/9093/profile_image_361809055094_2287229.jpg",
        "mapped_content_url": "https://chilkat.zendesk.com/system/photos/3601/0327/9093/profile_image_361809055094_2287229.jpg",
        "content_type": "image/jpeg",
        "size": 2587,
        "width": 40,
        "height": 40,
        "inline": false,
        "thumbnails": [
          {
            "url": "https://chilkat.zendesk.com/api/v2/attachments/360103279113.json",
            "id": 360103279113,
            "file_name": "profile_image_361809055094_2287229_thumb.jpg",
            "content_url": "https://chilkat.zendesk.com/system/photos/3601/0327/9093/profile_image_361809055094_2287229_thumb.jpg",
            "mapped_content_url": "https://chilkat.zendesk.com/system/photos/3601/0327/9093/profile_image_361809055094_2287229_thumb.jpg",
            "content_type": "image/jpeg",
            "size": 1980,
            "width": 32,
            "height": 32,
            "inline": false
          }
        ]
      },
      "locale_id": 1,
      "locale": "en-US",
      "organization_id": null,
      "role": "end-user",
      "verified": false,
      "external_id": null,
      "tags": [
      ],
      "alias": null,
      "active": true,
      "shared": false,
      "shared_agent": false,
      "last_login_at": null,
      "two_factor_auth_enabled": false,
      "signature": null,
      "details": null,
      "notes": null,
      "role_type": null,
      "custom_role_id": null,
      "moderator": false,
      "ticket_restriction": "requested",
      "only_private_comments": false,
      "restricted_agent": true,
      "suspended": false,
      "chat_only": false,
      "default_group_id": null,
      "user_fields": {}
    },
    {
      "id": 361810194934,
      "url": "https://chilkat.zendesk.com/api/v2/users/361810194934.json",
      "name": "matt",
      "email": "matt@chilkat.io",
      "created_at": "2018-04-14T20:58:33Z",
      "updated_at": "2018-04-14T20:59:40Z",
      "time_zone": "Central Time (US & Canada)",
      "phone": null,
      "shared_phone_number": null,
      "photo": null,
      "locale_id": 1,
      "locale": "en-US",
      "organization_id": 360015071793,
      "role": "end-user",
      "verified": false,
      "external_id": null,
      "tags": [
        "lizard",
        "gecko"
      ],
      "alias": "",
      "active": true,
      "shared": false,
      "shared_agent": false,
      "last_login_at": null,
      "two_factor_auth_enabled": false,
      "signature": null,
      "details": "",
      "notes": "Likes coffee",
      "role_type": null,
      "custom_role_id": null,
      "moderator": false,
      "ticket_restriction": "requested",
      "only_private_comments": false,
      "restricted_agent": true,
      "suspended": false,
      "chat_only": false,
      "default_group_id": null,
      "user_fields": {}
    },
    {
      "id": 361811376954,
      "url": "https://chilkat.zendesk.com/api/v2/users/361811376954.json",
      "name": "Roger Wilco",
      "email": "roger@chilkat.io",
      "created_at": "2018-04-14T23:09:24Z",
      "updated_at": "2018-04-14T23:09:24Z",
      "time_zone": "Bogota",
      "phone": null,
      "shared_phone_number": null,
      "photo": null,
      "locale_id": 1,
      "locale": "en-US",
      "organization_id": null,
      "role": "end-user",
      "verified": false,
      "external_id": null,
      "tags": [
      ],
      "alias": null,
      "active": true,
      "shared": false,
      "shared_agent": false,
      "last_login_at": null,
      "two_factor_auth_enabled": false,
      "signature": null,
      "details": null,
      "notes": null,
      "role_type": null,
      "custom_role_id": null,
      "moderator": false,
      "ticket_restriction": "requested",
      "only_private_comments": false,
      "restricted_agent": true,
      "suspended": false,
      "chat_only": false,
      "default_group_id": null,
      "user_fields": {}
    }
  ],
  "next_page": null,
  "previous_page": null,
  "count": 4
}