I have been trying to use the Zendesk API through Rstudio for a while now and I can't get the data into a usable format or find a logical way to use the data as it is.
I have used many ways to get the data however the one that I have had the most luck with is this query:
zendesk <- httr::GET("https://xxx.zendesk.com/api/v2/users.json", authenticate(username, password))
status_code(zendesk)
zendesk
users <- content(zendesk, "parsed")
users
And when I run users
i get the data in the following output:
$users[[100]]
$users[[100]]$id
[1] 51666*****
$users[[100]]$url
[1] "https://xxx.zendesk.com/api/v2/users/51666*****.json"
$users[[100]]$name
[1] "xxxx, xxxx"
$users[[100]]$email
[1] "xxx@xxx.com"
$users[[100]]$created_at
[1] "2016-09-22T12:19:01Z"
$users[[100]]$updated_at
[1] "2017-11-27T16:08:17Z"
$users[[100]]$time_zone
[1] "London"
$users[[100]]$iana_time_zone
[1] "Europe/London"
$users[[100]]$phone
NULL
$users[[100]]$shared_phone_number
NULL
$users[[100]]$photo
NULL
$users[[100]]$locale_id
[1] 1xxxx
$users[[100]]$locale
[1] "en-gb"
$users[[100]]$organization_id
[1] 223xxxxxxx
$users[[100]]$role
[1] "end-user"
$users[[100]]$verified
[1] FALSE
$users[[100]]$external_id
NULL
$users[[100]]$tags
list()
$users[[100]]$alias
NULL
$users[[100]]$active
[1] TRUE
$users[[100]]$shared
[1] FALSE
$users[[100]]$shared_agent
[1] FALSE
$users[[100]]$last_login_at
NULL
$users[[100]]$two_factor_auth_enabled
[1] FALSE
$users[[100]]$signature
NULL
$users[[100]]$details
NULL
$users[[100]]$notes
NULL
$users[[100]]$role_type
NULL
$users[[100]]$custom_role_id
NULL
$users[[100]]$moderator
[1] FALSE
$users[[100]]$ticket_restriction
[1] "requested"
$users[[100]]$only_private_comments
[1] FALSE
$users[[100]]$restricted_agent
[1] TRUE
$users[[100]]$suspended
[1] FALSE
$users[[100]]$chat_only
[1] FALSE
$users[[100]]$default_group_id
NULL
$users[[100]]$report_csv
[1] FALSE
$users[[100]]$user_fields
$users[[100]]$user_fields$department
NULL
$users[[100]]$user_fields$description
NULL
This is only one result thats outputted, each user is displayed in this list format. Is there any way that I can get this into a data table?
Ideally I would like the data to be 'inverted' from the list above and shown as follows :
ID URL NAME EMAIL CREATED AT
A XXX XXX XXX XXX
B XXX XXX XXX XXX
C XXX XXX XXX XXX
This is the output when I run zendesk
:
Response [https://xxx.zendesk.com/api/v2/users.json]
Date: 2019-02-26 10:46
Status: 200
Content-Type: application/json; charset=UTF-8
Size: 92.9 kB
Its driving me crazy, ive used Extracting data from an API using R and Extracting data from an API using R to try and help but I cant work it out.
Hope someone can help.
Thanks