r-lib / gmailr

Access the Gmail RESTful API from R.
https://gmailr.r-lib.org
Other
229 stars 56 forks source link

Error in !drop : invalid argument type #83

Closed jim0wheel closed 7 years ago

jim0wheel commented 7 years ago

I'm trying to save the attachment from the most recently received email, but getting the following error message when using the id() function:

Error in !drop : invalid argument type
In addition: Warning message:
id() is deprecated 

Full code below:

library(gmailr)

setwd("D:/R Data")

my_message = messages("report", 1, NULL, TRUE)

messageid = id(my_message,"message_id")

path = "C:/Users/xxx/Desktop"

attachments = save_attachments(message(messageid),NULL,path,"me")
jim0wheel commented 7 years ago

Full console output:

> library(gmailr)
> 
> setwd("D:/R Data")
> 
> my_message = messages("report", 1, NULL, TRUE)
Auto-refreshing stale OAuth token.
> 
> messageid = id(my_message,"message_id")
Error in !drop : invalid argument type
In addition: Warning message:
id() is deprecated 
> 
> path = "C:/Users/xxx/Desktop""
> 
> attachments = save_attachments(message(messageid),NULL,path,"me")
Error: is_string(id) is not TRUE
jimhester commented 7 years ago

Can you run traceback() after the error message?

jim0wheel commented 7 years ago
2: id_var(.variables[[1]], drop = drop)
1: id(my_message, "message_id")
jim0wheel commented 7 years ago

The values I'm getting are as follows:

> my_message
        message_id        thread_id
1 15e9e1538b37a6c8 15e7a3e2d71cefb2
> messageid
$messages
$messages[[1]]
$messages[[1]]$id
[1] "15e9e1538b37a6c8"

$messages[[1]]$threadId
[1] "15e7a3e2d71cefb2"

$resultSizeEstimate
[1] 8
jimhester commented 7 years ago

The id issue is because you have dplyr attached and it also has an id() function. use gmailr::id() to make sure you are calling the gmailr function.

jim0wheel commented 7 years ago

What an idiot! That fixed it! Thanks Jim!