This code was working perfectly fine until 2021. After a long time ran this for some other project. The cals are successful with 200 status, but Not sure what is the reason the saved pdf or png file does not open. The error I get when trying to open the pdf file is "Adobe Acrobat could not open 'test.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded)."
httr::GET(
url ="https://public.tableau.com/app/profile/joti.gautam/viz/Book3_16512272064090/Dashboard.pdf",
httr::write_disk(here::here("test.pdf"),overwrite = T),
httr::progress()
)
CodePudding user response:
You are getting a 200 because the request successfully returns html. It doesn't link directly to a pdf. A little snooping in the developer tools reveals the correct url for the actual pdf:
url <- paste0("https://public.tableau.com/views/Book3_16512272064090/",
"Dashboard.pdf?:display_static_image=y&:bootstrapWhenNotified=",
"true&:embed=true&:language=en-US&:embed=y&:showVizHome=n",
"&:apiID=host1#navType=0&navSrc=Parse")
httr::GET(url,
httr::write_disk(here::here("test.pdf"),overwrite = T),
httr::progress()
)
test.pdf