Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Attempt to us api_create to post my plotly graph gives "lexical error"

I have a plotly object (one of the examples from the ggplotly help). When I try to post it on plotly using api_create() I get the following message:

Error: lexical error: invalid char in json text.
!DOCTYPE html>
(right here) ------^

Any ideas how to figure out what is going on?

The R code is:

if (!require(devtools)) install.packages(“devtools”)
if (!require(plotly)) install.packages(“plotly”)
if (!require(ggplot2)) devtools::install_github(‘hadley/ggplot2’)
if (!require(maps)) install.packages(“maps”)

data(canada.cities, package = “maps”)
viz <- ggplot(canada.cities, aes(long, lat)) +
borders(regions = “canada”) +
coord_equal() +
geom_point(aes(text = name, size = pop), colour = “red”, alpha = 1/2)
TestPlot <- ggplotly(viz, tooltip = c(“text”, “size”))

api_create(TestPlot,filename = “Test”)

R version 3.4.0
Package versions are:
[1] plotly_4.7.0 devtools_1.13.2 maps_3.2.0 ggplot2_2.2.1.9000[details=Summary]This text will be hidden[/details]

I keep having this same issue using api_create. I’ve had no problem in the past pushing to plotly from R so no idea what is going on.

Still having the same issue, even after reinstalling the latest version. Has anyone found a solution yet?

I’m also still having the same issue.

Seems like this has to be a proxy issue since I’m not having the same issue at home.
Tried using httr package to no avail:

use httr package

set_config(use_proxy(url=“”, port=xxxx, username=“USERNAME”, password=“PASSWORD”, auth=“basic”))
set_config(config(ssl_verifypeer = 0L))

I have the exact same issue. Did anyone manage to solve it.