I'm writing a script in Power BI Service using R that will automatically download a specific dataset into a file on OneDrive. However, I keep getting this error:
can only open URLs for readingError in file(file, ifelse(append, "a", "w")) : cannot open the connection Calls: write.table -> file Execution halted
The OneDrive folder has restricted access (requires username and password) and I am trying to pass a URL with the user credentials embedded in it along with the file name. However, it does not seem to work and throw the above error message.
If I used a local file path to access the OneDrive folder, I have no problem exporting the table to that OneDrive folder using Power BI Desktop but been encountering problems with Power BI Service with the following error message:
In file(file, ifelse(append, "a", "w")) : cannot open the connection. In addition: Warning message: In file(file, ifelse(append, "a", "w")) : cannot open file "filepath/dataset.csv": Permission denied
This is the code I used using a URL:
require(gdata)
write.csv(trim(dataset), file = "filepath/dataset.csv", row.names = F)
plot(dataset)
This is the code I used when exporting using a local path:
require(gdata)
write.csv(trim(dataset), file = "https://company.sharepoint.com/site/sitename/Document/UserDocumentFolder?login=username&password=password/dataset.csv", row.names = F)
plot(dataset)
I suspect the problem may be how I crafted the URL to access OneDrive on the cloud. Is it even possible to write an R file through a secured URL?