Request to API using httr2 not changing like httr - r

I'm trying to switch from the R package httr to httr2
httr2 is the modern rewrite and should be superior, but I'm a novice when it comes to APIs and coding and I've been stuck all day trying to figure out what I'm doing wrong. I can only get httr to work with this API.
I believe I am messing up with adding the headers, as I don't think the path sent to the API is changing. So my problem is the request gets rejected simply because the API can't read my API key.
Here is what I have done in httr2:
gov_url <- "https://api.dummy.gov/aaa/bb/cc"
resp <- request(gov_url) %>%
req_headers(
param1 = "10",
api_key = "abcdefg",
param2 = "xyz",
param3 = "09/10/2022"
) %>%
req_dry_run()
Output:
GET /destiny/v1/placeholder HTTP/1.1
Host: api.dummy.gov
User-Agent: httr2/0.2.1 r-curl/4.3.2 libcurl/7.64.1
Accept: */*
Accept-Encoding: deflate, gzip
param1: 10
api_key: abcdefg
param2: xyz
param3: 09/10/2022
The first line of that output hasn't changed.
GET /destiny/v1/placeholder HTTP/1.1
Showing the structure of the 'resp' object with str(resp)
List of 7
$ url : chr "https://api.dummy.gov/destiny/v1/placeholder"
$ method : NULL
$ headers :List of 4
..$ param1 : chr "10"
..$ api_key : chr "abcdefg"
..$ param2 : chr "xyz"
..$ param3 : chr "09/10/2022"
$ body : NULL
$ fields : list()
$ options : list()
$ policies: list()
- attr(*, "class")= chr "httr2_request"
Sending the request with resp %>% req_perform(verbosity = 2) gives me this error:
HTTP/1.1 403 Forbidden
---
"error":
"code": "API_KEY_MISSING",
"message": "No api_key was supplied. Please submit with a valid API key."
But when I use httr though, I can pull data from the API.
gov_url <- "https://api.dummy.gov/destiny/v1/placeholder"
query_params <- list('param1' = '10',
'api_key' = "abcdefg",
'param2' = 'xyz',
'param3' = '09/10/2022')
gov_api <- GET(path, query = query_params)
Showing structure str(gov_api) shows the path has changed which is quite good because it matches the example input provided from the API
List of 10
$ url : chr "https://api.dummy.gov/destiny/v1/placeholder?param1=10&api_key=abcdefg&param2"| __trunc
$ status_code: int 200
$ headers :List of 19
..$ xyz : chr "1"
..$ abc : chr "application/json"
..$ edg : chr "something"
And http_status(gov_api) shows its making the connection
$message
"Success: (200) OK"
Then I'm able to successfully use httr to pull data from the API.
Thank you to anyone who has read this far. I'd appreciate any feedback if possible.
Other things I've tried to no avail:
!!! to evaluate the list of expressions
Sending the API a list named queue like I do in httr
Sending the param "accept" = "application/json"
Different syntax, quotations

I'm not sure what you're after, but if you want to reproduce same comportement as httr with httr2 you can do :
library(httr2)
gov_url <- "https://api.dummy.gov/aaa/bb/cc"
param <- list(param1 = "10",
api_key = "abcdefg",
param2 = "xyz",
param3 = "09/10/2022")
resp <- request(gov_url) %>%
req_url_query(!!!param)
resp$url
#> [1] "https://api.dummy.gov/aaa/bb/cc?param1=10&api_key=abcdefg&param2=xyz&param3=09%2F10%2F2022"
Perhaps the confusion come from the fact that in httr2 you're setting headers and in httr you're setting query.

Related

Get user detail from rstudio connect published shiny app into app.R code [duplicate]

I want to get User's IP, User's window ID and User's Server Access time
I can get User's IP with below code but Other things can't get....
getting User's IP code is
ip <- session$request$REMOTE_ADDR at server.R
How to get User's window ID and User's Server Access time ????
Long-story-short, there is a limit to what "you" (the app and therefore you, the dev) can know about the connection. I've put in similar requests for some more with RStudio professional support, and what I have below is the current capability. I hope (with no advertised timeline) that more will eventually be available.
I have RStudio Connect, which is technically a different product but similar underlying methods and I believe a lot of shared code.
Here's a shiny app that helps you "discover" things from session. I filter out most of the environment-like variables in session that are either packed full of functions or just not something useful. It's possible I've filtered out too much, you might want to play with it to see if there is more.
library(shiny)
ui <- bootstrapPage(
h3("Parsed query string"),
verbatimTextOutput("queryText"),
h3("URL components"),
verbatimTextOutput("sessionText"),
h3("EnvVars"),
verbatimTextOutput("envvarText")
)
server <- function(input, output, session) {
# Parse the GET query string
output$queryText <- renderText({
query <- parseQueryString(session$clientData$url_search)
# Return a string with key-value pairs
paste(names(query), query, sep = "=", collapse=", ")
})
# Return the components of the URL in a string:
output$sessionText <- renderText({
cls <- sapply(session, function(a) class(a)[1])
nms <- names(cls[ cls %in% c("list", "character", "numeric", "integer",
"NULL", "logical", "environment", "reactivevalues" ) ])
nms <- setdiff(nms, ".__enclos_env__")
paste(
capture.output(
str(
sapply(nms,
function(sessnm) {
if (inherits(session[[sessnm]], c("environment", "reactivevalues"))) {
sapply(names(session[[sessnm]]), function(nm) session[[sessnm]][[nm]], simplify = FALSE)
} else if (inherits(session[[sessnm]], c("character", "numeric", "integer"))) {
session[[sessnm]]
} else class(session[[sessnm]])
}, simplify = FALSE),
nchar.max = 1e5,
vec.len = 1e5
)
),
collapse = "\n"
)
})
# Dump the environment variables
output$envvarText <- renderText({
paste(
capture.output(
str(as.list(Sys.getenv()))
),
collapse = "\n"
)
})
}
shinyApp(ui, server)
Here's some sample output, cleansed for private information. (Context for this output: I changed the server's IP address to be 111.222.333.444, otherwise that should be the external IP address. Also, this is behind an nginx reverse proxy for a few reasons, so REMOTE_ADDR (for instance) is not very exciting ... but it normally might be for you.)
List of 10
$ groups : chr [1:45] "Admins" "Analytics" "Synology Desktop"
$ user : chr "r2evans"
$ userData : Named list()
$ singletons : chr(0)
$ request :List of 24
..$ HTTP_UPGRADE : chr "websocket"
..$ HTTP_CONNECTION : chr "Upgrade"
..$ HTTP_GUID : chr "_6433vf0"
..$ QUERY_STRING : chr ""
..$ httpuv.version :Classes 'package_version', 'numeric_version' hidden list of 1
.. ..$ : int [1:3] 1 5 2
..$ SERVER_NAME : chr "127.0.0.1"
..$ SCRIPT_NAME : chr ""
..$ SERVER_PORT : chr "40386"
..$ REMOTE_PORT : chr "52858"
..$ HTTP_SEC_WEBSOCKET_VERSION : chr "13"
..$ rook.input :Classes 'NullInputStream', 'R6' <NullInputStream>
Public:
close: function ()
read: function (l = -1L)
read_lines: function (n = -1L)
rewind: function ()
..$ PATH_INFO : chr "/websocket/"
..$ rook.version : chr "1.1-0"
..$ rook.errors :Classes 'ErrorStream', 'R6' <ErrorStream>
Public:
cat: function (..., sep = " ", fill = FALSE, labels = NULL)
flush: function ()
..$ HTTP_X_FORWARDED_FOR : chr "111.222.333.444:61928, ::1"
..$ HTTP_SHINY_SERVER_CREDENTIALS: chr "{\"user\":\"r2evans\",\"groups\":[\"Admins\",\"Analytics\",\"Synology Desktop\"]}"
..$ HTTP_SEC_WEBSOCKET_KEY : chr "NbavAciNEKYiS1AN/NGlVQ=="
..$ HTTP_SHINY_SHARED_SECRET : chr "65567ccb5db3d2990df150611eb022f4"
..$ REMOTE_ADDR : chr "127.0.0.1"
..$ HEADERS : Named chr [1:10] "Upgrade" "_6433vf0" "127.0.0.1:40386" "NbavAciNEKYiS1AN/NGlVQ==" "13" "{\"user\":\"r2evans\",\"groups\":[\"Admins\",\"Analytics\",\"Synology Desktop\"]}" "65567ccb5db3d2990df150611eb022f4" "websocket" "Go-http-client/1.1" "111.222.333.444!:61928, ::1"
.. ..- attr(*, "names")= chr [1:10] "connection" "guid" "host" "sec-websocket-key" "sec-websocket-version" "shiny-server-credentials" "shiny-shared-secret" "upgrade" "user-agent" "x-forwarded-for"
..$ rook.url_scheme : chr "http"
..$ REQUEST_METHOD : chr "GET"
..$ HTTP_USER_AGENT : chr "Go-http-client/1.1"
..$ HTTP_HOST : chr "127.0.0.1:40386"
$ closed : chr "logical"
$ token : chr "3a358fb6a0d42c688ea8693b67d448cb"
$ clientData :List of 13
..$ output_queryText_hidden : logi FALSE
..$ output_sessionText_hidden: logi FALSE
..$ output_envvarText_hidden : logi FALSE
..$ url_search : chr ""
..$ url_hash_initial : chr ""
..$ singletons : chr ""
..$ url_protocol : chr "https:"
..$ allowDataUriScheme : logi TRUE
..$ url_port : chr ""
..$ url_hostname : chr "server.mydomain.com"
..$ pixelratio : int 2
..$ url_hash : chr ""
..$ url_pathname : chr "/content/23/"
$ input : Named list()
$ progressStack:List of 10
..$ .__enclos_env__:<environment: 0x652f8e8>
..$ clone :function (deep = FALSE)
..$ as_list :function ()
..$ size :function ()
..$ peek :function ()
..$ pop :function ()
..$ push :function (..., .list = NULL)
..$ initialize :function (init = 20L)
..$ private :<environment: 0x652fbc0>
..$ self :<environment: 0x652f8e8>
And the environment variables:
List of 42
$ EDITOR : chr "vi"
$ HOME : chr "/home"
$ LANG : chr "en_US.UTF-8"
$ LD_LIBRARY_PATH : chr "/usr/lib/R/lib:/usr/lib/x86_64-linux-gnu:/usr/lib/jvm/default-java/jre/lib/amd64/server"
$ LN_S : chr "ln -s"
$ LOGNAME : chr "rstudio-connect"
$ MAKE : chr "make"
$ PAGER : chr "/usr/bin/pager"
$ PATH : chr "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/opt/rstudio-connect/ext/pandoc2"
$ PWD : chr "/opt/rstudio-connect/mnt/app"
$ R_ARCH : chr ""
$ R_BROWSER : chr "xdg-open"
$ R_BZIPCMD : chr "/bin/bzip2"
$ R_CONFIG_ACTIVE : chr "rsconnect"
$ R_DOC_DIR : chr "/usr/share/R/doc"
$ R_GZIPCMD : chr "/bin/gzip -n"
$ R_HOME : chr "/usr/lib/R"
$ R_INCLUDE_DIR : chr "/usr/share/R/include"
$ R_LIBS : chr "/opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/3.5.3:"
$ R_LIBS_SITE : chr "/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library"
$ R_LIBS_USER : chr "~/R/x86_64-pc-linux-gnu-library/3.5"
$ R_PAPERSIZE : chr "letter"
$ R_PAPERSIZE_USER : chr "letter"
$ R_PDFVIEWER : chr "/usr/bin/xdg-open"
$ R_PLATFORM : chr "x86_64-pc-linux-gnu"
$ R_PRINTCMD : chr "/usr/bin/lpr"
$ R_RD4PDF : chr "times,inconsolata,hyper"
$ R_SESSION_TMPDIR : chr "/opt/rstudio-connect/mnt/tmp/Rtmp3WkNTY"
$ R_SHARE_DIR : chr "/usr/share/R/share"
$ RSTUDIO_PANDOC : chr "/opt/rstudio-connect/ext/pandoc2"
$ R_SYSTEM_ABI : chr "linux,gcc,gxx,gfortran,?"
$ R_TEXI2DVICMD : chr "/usr/bin/texi2dvi"
$ R_UNZIPCMD : chr "/usr/bin/unzip"
$ R_ZIPCMD : chr "/usr/bin/zip"
$ SED : chr "/bin/sed"
$ SHINY_PORT : chr "40386"
$ SHINY_SERVER_VERSION: chr "1.8.2-10"
$ SHLVL : chr "0"
$ TAR : chr "/bin/tar"
$ TMPDIR : chr "/opt/rstudio-connect/mnt/tmp"
$ USER : chr "rstudio-connect"
$ USERNAME : chr "rstudio-connect"
Ultimately, publish this app, visit it, and see what you find one your instance.
Not requested, but included for completeness: here's an equivalent plumber API hit:
library(jsonlite)
library(plumber)
#* #get /clientdata
function(req, res){
classes <- sapply(req, function(a) head(class(a), n=1))
classes <- classes[! classes %in% c("ErrorStream", "NullInputStream") ]
classes <- classes[ ! names(classes) %in% c("args", "httpuv.version") ]
lapply(setNames(nm=names(classes)), function(nm) req[[nm]])
}
With output:
{
"SERVER_NAME": [
"127.0.0.1"
],
"HTTP_X_FORWARDED_FOR": [
"111.222.333.555:54590, 127.0.0.1"
],
"HTTP_ACCEPT": [
"application/json"
],
"HTTP_DNT": [
"1"
],
"SERVER_PORT": [
"33632"
],
"rook.url_scheme": [
"http"
],
"REQUEST_METHOD": [
"GET"
],
"HTTP_X_ARR_LOG_ID": [
"e5bdaca6-dcd7-4ca0-87d5-0d54927244b5"
],
"rook.version": [
"1.1-0"
],
"HTTP_X_ARR_SSL": [
"..., CN=*.mydomain.com"
],
"postBody": [],
"HTTP_RSTUDIO_CONNECT_CREDENTIALS": [
"{\"user\":\"r2evans\",\"groups\":[\"Admins\",\"Analytics\",\"Synology Desktop\"]}"
],
"HTTP_USER_AGENT": [
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0"
],
"SCRIPT_NAME": [
""
],
"cookies": [],
"HTTP_ACCEPT_LANGUAGE": [
"en-US,en;q=0.5"
],
"HTTP_PLUMBER_SHARED_SECRET": [
"..."
],
"HTTP_REFERER": [
"https://server.mydomain.com/content/28/__swagger__/"
],
"REMOTE_PORT": [
"48684"
],
"HTTP_ACCEPT_ENCODING": [
"gzip, deflate, br"
],
"HTTP_MAX_FORWARDS": [
"10"
],
"HTTP_X_ORIGINAL_URL": [
"/content/28/clientdata"
],
"HTTP_HOST": [
"127.0.0.1:33632"
],
"HEADERS": [
"application/json",
"gzip, deflate, br",
"en-US,en;q=0.5",
"1",
"127.0.0.1:33632",
"10",
"...",
"https://server.mydomain.com/content/28/__swagger__/",
"https://server.mydomain.com/content/28",
"{\"user\":\"r2evans\",\"groups\":[\"Admins\",\"Analytics\",\"Synology Desktop\"]}",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0",
"e5bdaca6-dcd7-4ca0-87d5-0d54927244b5",
"..., CN=*.mydomain.com",
"111.222.333.555:54590, 127.0.0.1",
"/content/28/clientdata",
"https://server.mydomain.com:443/content/28/clientdata"
],
"HTTP_X_RSC_REQUEST": [
"https://server.mydomain.com:443/content/28/clientdata"
],
"HTTP_RSTUDIO_CONNECT_APP_BASE_URL": [
"https://server.mydomain.com/content/28"
],
"PATH_INFO": [
"/clientdata"
],
"QUERY_STRING": [
""
],
"REMOTE_ADDR": [
"127.0.0.1"
]
}

Extracting All Emails Using GmailR

I'm trying to extract all the emails from my gmail account to do some analysis. The end goal is a dataframe of emails. I'm using the gmailR package.
So far I've extracted all the email threads and "expanded" them by mapping all the thread IDs to gm_thread(). Here's the code for that:
threads <- gm_threads(num_results = 5)
thread_ids <- gm_id(threads)
#extract all the thread ids
threads_expanded <- map(thread_ids, gm_thread)
This returns a list of all the threads. The structure of this is a list of gmail_thread objects. When you drill down one level into the list of thread objects, str(threads_expanded[[1]], max.level = 1), you get a single thread object which looks like:
List of 3
$ id : chr "xxxx"
$ historyId: chr "yyyy"
$ messages :List of 3
- attr(*, "class")= chr "gmail_thread"
Then, if you drill down further into the messages composing the threads, you start to get the useful info. str(threads_expanded[[1]]$messages, max.level = 1) gets you a list of the gmail_message objects for that thread:
List of 3
$ :List of 8
..- attr(*, "class")= chr "gmail_message"
$ :List of 8
..- attr(*, "class")= chr "gmail_message"
$ :List of 8
..- attr(*, "class")= chr "gmail_message"
Where I'm stuck is actually extracting all the useful information from each email within all the threads. The end goal is a dataframe with a column for the message_id, thread_id, to, from, etc. I'm imagining something like this:
message_id | thread_id | to | from | ... |
-------------------------------------------------------------------------
1234 | abcd | me#gmail.com | pam#gmail.com | ... |
1235 | abcd | pam#gmail.com | me#gmail.com | ... |
1236 | abcf | me#gmail.com | tim#gmail.com | ... |
It's not the prettiest answer, but it works. I'm going to work on vectorizing it later:
threads <- gm_threads(num_results = 5)
thread_ids <- gm_id(threads)
#extract all the thread ids
threads_expanded <- map(thread_ids, gm_thread)
msgs <- vector()
for(i in (1:length(threads_expanded))){
msgs <- append(msgs, values = threads_expanded[[i]]$messages)
}
#extract all the individual messages from each thread
msg_ids <- unlist(map(msgs, gm_id))
#get the message id for each message
msg_body <- vector()
#get message body, store in vector
for(msg in msgs){
body <- gm_body(msg)
attchmnt <- nrow(gm_attachments(msg))
if(length(body) != 0 && attchmnt == 0){
#does not return a null value, rather an empty list or list
of length 0, so if,
#body is not 0 (there is something there) and there are no attachemts,
#add it to vector
msg_body <- append(msg_body, body)
#if there is no to info, fill that spot with an empty space
}
else{
msg_body <- append(msg_body, "")
#if there is no attachment but the body is also empty add "" to the list
}
}
msg_body <- unlist(msg_body)
msg_datetime <- msgs %>%
map(gm_date) %>%
unlist()%>%
dmy_hms()
#get datetime info, store in vector
message_df <- tibble(msg_ids, msg_datetime, msg_body)
#all the other possible categories, e.g., to, from, cc, subject, etc.,
#either use a similar for loop or a map call

R: Httr package - connection with API, Error 1200: description" : "__all__ : img or url parameter is needed

I am very newbie in HTTR and connection with API by R. I cannot connect with F.A.C.E API (documentation: https://face-api.sightcorp.com/dev-documentation/)
library(httr)
library("XML")
library("jsonlite")
library(RCurl)
key = 'XXX'
img = 'C:\\my_image.jpg'
The query:
my_json <- POST('https://api-face.sightcorp.com/api/detect/', add_headers(app_key = key, img = img, ethnicity = TRUE ))
print(my_json)
and the answer:
Response [https://api-face.sightcorp.com/api/detect/]
Date: 2019-02-19 20:26
Status: 200
Content-Type: application/json
Size: 88 B
{
"error_code" : 1200,
"description" : "__all__ : img or url parameter is needed."
How shall I implement img or url adress into the code to obtain API analysis?
The solution is as follows:
my_body = list('app_key'=key, 'img'= upload_file(img.url))
my_json <- POST('https://api-face.sightcorp.com/api/detect/',body = my_body)

Error in parse_aws_s3_response, Forbidden (http 403)

I a
I'm trying to use aws.s3 library to load data into S3. Below is my code below:
Sys.setenv("AWS_ACCESS_KEY_ID" = ".............",
"AWS_SECRET_ACCESS_KEY" = "...............",
"AWS_DEFAULT_REGION" = "......")
view bucket:
get_bucket(bucket = "....",
check_region = FALSE,
verbose = TRUE)
The code above works and contents of the bucket is returned.
save object to s3:
s3save(data,
object = ".....",
bucket = ".....")
Error return:
List of 4
$ Code : chr "AccessDenied"
$ Message : chr "Access Denied"
$ RequestId: chr ""
$ HostId : chr ""
- attr(*, "headers")=List of 6
..$ x-amz-request-id : chr ""
..$ x-amz-id-2 : chr ""
..$ content-type : chr "application/xml"
..$ transfer-encoding: chr "chunked"
..$ date : chr "Tue, 05 Sep 2017 13:23:42 GMT"
..$ server : chr "AmazonS3"
..- attr(*, "class")= chr [1:2] "insensitive" "list"
- attr(*, "class")= chr "aws_error"
- attr(*, "request_canonical")= chr "GET\n/"| __truncated__
- attr(*, "request_string_to_sign")= car ""| __truncated__
- attr(*, "request_signature")= chr "AWS4-HMAC-SHA256 Credential=|
__truncated__
NULL
Error in parse_aws_s3_response(r, Sig, verbose = verbose) :
Forbidden (HTTP 403).
Any solution to this problem.
It seems like your IAM account is not authorized to do that operation.
If you're the owner of the AWS account, you can go to AWS Service IAM, click on users, choose this IAM user and add the necessary authorizations to it.
I got the same error message when attempting
get_bucket("collidr-api")
All I needed to do was add the region name like so
get_bucket("collidr-api", region="asia-south-01")
Then it worked. I found that info here.
#audiracmichelle, #Prakhar, use the function put_object from aws.s3 library as shown below. The object input argument to function put_object is the name(string) the object should have in s3.
You can first write a serialized object (in this case data) from memory with:
in_mem_obj <- rawConnection(raw(0), "w")
utils::write.table(data, in_mem_obj, sep = "\t", na = "", quote = TRUE,
row.names = FALSE, fileEncoding="UTF-8")
Then save object to S3 bucket:
put_object(rawConnectionValue(in_mem_obj),
object = FILEPATH/FILENAME,
bucket = BUCKET,
headers = c('x-amz-server-side-encryption' = 'AES256'),
key = AWS_ACCESS_KEY_ID,
secret = AWS_SECRET_ACCESS_KEY,
region = AWS_REGION,
check_region = FALSE)

What does "hidden list" in the output of `str()` mean?

In attempting to Answer this Question I came across this in the output of str()
## R reference
rref <- bibentry(bibtype = "Manual",
title = "R: A Language and Environment for Statistical Computing",
author = person("R Development Core Team"),
organization = "R Foundation for Statistical Computing",
address = "Vienna, Austria",
year = 2010,
isbn = "3-900051-07-0",
url = "http://www.R-project.org/")
> str(rref)
Class 'bibentry' hidden list of 1
$ :List of 7
..$ title : chr "R: A Language and Environment for Statistical Computing"
..$ author :Class 'person' hidden list of 1
.. ..$ :List of 5
.. .. ..$ given : chr "R Development Core Team"
.. .. ..$ family : NULL
.. .. ..$ role : NULL
.. .. ..$ email : NULL
.. .. ..$ comment: NULL
..$ organization: chr "R Foundation for Statistical Computing"
..$ address : chr "Vienna, Austria"
..$ year : chr "2010"
..$ isbn : chr "3-900051-07-0"
..$ url : chr "http://www.R-project.org/"
..- attr(*, "bibtype")= chr "Manual"
In particular, I'm puzzled by this bit:
> str(rref)
Class 'bibentry' hidden list of 1
$ :List of 7
What does the "hidden list" bit refer to? What kind of object is this? Is this just some formatting output from str() when there is only a single component in the object that is itself a list? If so how is there a way to force str() to show the full structure?
This seems like an artefact of str. My interpretation is that the words hidden list are printed in the output of str if the obect is not a pairlist.
Since your object is of class bibtex, and there is no str method for bibtex, the method utils:::str.default is used to describe the structure.
Condensed extract from str.default:
...
if (is.list(object)) {
i.pl <- is.pairlist(object)
...
cat(if (i.pl)
"Dotted pair list"
else if (irregCl)
paste(pClass(cl), "hidden list")
else "List", " of ", le, "\n", sep = "")
...
}
The key bit that defines irregCl is:
....
else {
if (irregCl <- has.class && identical(object[[1L]],
object)) {
....
and that explain the hidden list bit - it hides the outer list if the object has a class and object and object[[1]] are identical. As you showed in the Answer you linked to, the [[ method returns an identical object if the list contains a single "bibentry" object.

Resources