eddelbuettel / rpushbullet

R interface to the awesome Pushbullet service
https://eddelbuettel.github.io/rpushbullet
94 stars 19 forks source link

Error in curl::handle_setheaders(h, .list = list(`Access-Token` = apikey)) : All headers must be strings. #38

Closed SamoPP closed 7 years ago

SamoPP commented 7 years ago

I have the following issues with RPushbullet (all libraries are up to date): ~$ R

R version 3.3.1 (2016-06-21) -- "Bug in Your Hair" Copyright (C) 2016 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R.

library(RPushbullet) Attaching RPushbullet version 0.2.0.2. Reading ~/.rpushbullet.json pbPost("note", "Test", "tesT") Error in curl::handle_setheaders(h, .list = list(Access-Token = apikey)) : All headers must be strings. sessionInfo() R version 3.3.1 (2016-06-21) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 16.04.1 LTS

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] RPushbullet_0.2.0.2

loaded via a namespace (and not attached): [1] curl_2.3 jsonlite_1.2

RPushbullet:::.getKey() [[1]] [1] "mysecretkey"

content of ~/.rpushbullet.json {"key":["mysecretkey"],"devices":["device1","device2","device3"],"names":["Firefox","iPad","phone","myVB"]}

restonslacker commented 7 years ago

The simple answer is that you need to remove the square brackets from around "mysecretkey". so it should look like this:

{"key":"mysecretkey","devices":["device1","device2","device3"],"names":["Firefox","iPad","phone","myVB"]}

Out of curiosity, did you create this file with the pbSetup() function? FYI, we're in the middle of making changes to RPushbullet, so if you have other issues you may want to install from CRAN, though even that one is a little out of date with respect to API changes that the Pushbullet service has made.

eddelbuettel commented 7 years ago

@restonslacker is spot on, and both the README.md and the help file rpushbullet-package show the suggested

"key": "...placey your api key here...",

as a straight key=value assignment, not an array.

SamoPP commented 7 years ago

@restonslacker : Yes, I used pbSetup() function to create ~/.rpushbullet.json . So, there is a problem in pbSetup() function...

eddelbuettel commented 7 years ago

Maybe try again after you refresh from master. At least it now prints prettily ie easier for humans.

We may need to control the autoboxing.

eddelbuettel commented 7 years ago

I could not replicate that right now. I did (obfuscating my key and device ids):

R> library(RPushbullet)
Attaching RPushbullet version 0.2.0.2.
Reading ~/.rpushbullet.json
R> pbSetup(conffile="/tmp/new.json")
Please enter your API key (aka 'Access Token': xxx
[1] "1. LGE Nexus 5X"
[1] "2. Htc Nexus 9"
[1] "3. Chrome"
Select a default device (0 for none): 1
R> q()
Save workspace image? [y/n/c]: n
edd@max:~$ cat /tmp/new.json 
{
  "key": "xxx",
  "devices": ["abc", "def", "ghi"],
  "names": ["LGE Nexus 5X", "Htc Nexus 9", "Chrome"],
  "defaultdevice": "LGE Nexus 5X"
}edd@max:~$ 
restonslacker commented 7 years ago

@SamoPP if you haven't already reinstalled from the current master can you please look at your description file to see if you have a block like the following near the bottom? I believe that devtools::install_github() provides this now.

Built: R 3.3.2; ; 2017-01-18 13:08:59 UTC; windows
RemoteType: github
RemoteHost: https://api.github.com
RemoteRepo: ggmap
RemoteUsername: dkahle
RemoteRef: master
RemoteSha: c6b7579207ed11093d615564a9dbf217eab05e27
GithubRepo: ggmap
GithubUsername: dkahle
GithubRef: master
GithubSHA1: c6b7579207ed11093d615564a9dbf217eab05e27

My hope is that you installed prior to yesterday morning when @eddelbuettel merged #37.

SamoPP commented 7 years ago

Updated from master and things now seem to work properly using pbSetup(). Thanks.