简体   繁体   English

通过 ZE1E1D3D405731238E0480CAF12 从 Sharepoint 读取和写入 Excel 和 CSV 文件

[英]Read and Write Excel and CSV files from Sharepoint via R

I am trying to read and write csv files in SharePoint.我正在尝试在 SharePoint 中读写 csv 文件。

mysite <- get_sharepoint_site(site_url="https://****.sharepoint.com/sites/Test/test.xlsx")
mysite <- get_sharepoint_site(site_url="https://****.sharepoint.com/:f:/Test/?!sue0De2rb"")

It is always showing some error: Loading Microsoft Graph login for default tenant Error in process_response(res, match.arg(http_status_handler), simplify): Not Found (HTTP 404).它总是显示一些错误:为默认租户加载 Microsoft Graph 登录 进程响应中的错误(res,match.arg(http_status_handler),简化):未找到(HTTP 404)。 Failed to complete operation.未能完成操作。 Message: The provided path does not exist, or does not represent a site.消息:提供的路径不存在,或不代表站点。

Loading Microsoft Graph login for default tenant Error in process_response(res, match.arg(http_status_handler), simplify): Not Found (HTTP 404).在 process_response(res, match.arg(http_status_handler), simple) 中为默认租户加载 Microsoft Graph 登录错误:未找到 (HTTP 404)。 Failed to complete operation.未能完成操作。 Message: The provided path does not exist, or does not represent a site.消息:提供的路径不存在,或不代表站点。

Does anyone know anything that can be done?有谁知道可以做些什么?

I already have a sync in my laptop who works however want to connect directly from SharePoint to automate the process, so I don't need to have my laptop on to read and write the files.我已经在我的笔记本电脑上进行了同步,但是我想直接从 SharePoint 连接以自动化该过程,所以我不需要打开笔记本电脑来读取和写入文件。

You need to login with AzureGraph before to get permissions您需要先使用 AzureGraph 登录才能获得权限

Something like that for instance if your want to connect with browser login:例如,如果您想通过浏览器登录进行连接:

# authenticate with AAD
# - on first login, call create_graph_login()
# - on subsequent logins, call get_graph_login()
gr <- create_graph_login()
#then
mysite <- get_sharepoint_site(site_url="https://****.sharepoint.com/sites/Test/test.xlsx")

Something like that for instance if your want to connect without browser:例如,如果您想在没有浏览器的情况下进行连接:

tenant <-  Sys.getenv("tenant")
secret <- Sys.getenv("secret")
app <- Sys.getenv("app")

# authenticate with AAD
# - on first login, call create_graph_login()
# - on subsequent logins, call get_graph_login()
gr <- create_graph_login(tenant=tenant, app=app, password=secret)
mysite <- get_sharepoint_site(site_url="https://****.sharepoint.com/sites/Test/test.xlsx", auth_type="device_code")

How do you get this information may vary if it your company, you might want to talk to your IT team or maybe follow this guide Authenticating via Microsoft如果是您的公司,您如何获取此信息可能会有所不同,您可能想与您的 IT 团队交谈,或者可能遵循本指南通过 Microsoft 进行身份验证

I am not 100% sure from your question, but based on the get_sharepoint_site method it looks like you're using the Microsoft365R package.我不能 100% 确定您的问题,但根据get_sharepoint_site方法,您似乎正在使用Microsoft365R package。

If this is the case, then unfortunately you cannot do what you're trying to do.如果是这种情况,那么不幸的是你不能做你想做的事。

I believe get_sharepoint_site can be used to get your Sharepoint site (ie, Test), but not to get files within that site (ie, Test/test.xlsx).我相信get_sharepoint_site可用于获取您的 Sharepoint 站点(即 Test),但不能用于获取该站点内的文件(即 Test/test.xlsx)。

This is the meaning of the errors you're seeing — "path... does not represent a site".这就是您所看到的错误的含义——“路径...不代表站点”。

Your best bet is probably to construct your own http requests to Microsoft's Graph API.您最好的选择可能是构建您自己的 http 请求到 Microsoft 的 Graph API。 Check the documentation to see what API endpoints are available - the get range and range update endpoints are probably worth looking at.查看文档以查看可用的 API 端点 - 获取范围范围更新端点可能值得一看。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM