I have found scattered articles about this topic but still can't find the exact resolution. I am trying to pull results from a Sharepoint list into R. In my browser I can hit "https://company.sharepoint.com/sites/SITE/site/_vti_bin/client.svc/Web/Lists/getbytitle('listName')/Items" and I can see the results I want. When I try to pull this via R I get a 403 error one way and a 200 the other way but I can't seem to get results. Unfortunately I can't provide a reprex because it's a private company SP site but here's what I've tried.
library(httr) username <- "email@example.com" password <- "password" call <- "https://company.sharepoint.com/sites/SITE/site/_vti_bin/client.svc/Web/Lists/getbytitle('listName')/Item" rest_call <- GET(call, authenticate(username,password,type="any")) #or type="basic"
This is what rest_call evaluates to:
Date: 2018-09-04 21:01
Size: 323 B
I've also tried this route:
library(RCurl) library(XML) handle <- handle("https://login.microsoftonline.com") path <- "extSTS.srf" # fields found in the login form. login <- list( amember_login = username ,amember_pass = password ,amember_redirect_url = "https://company.sharepoint.com/sites/SITE/site/_vti_bin/client.svc/Web/Lists/getbytitle('listName')/Item" ) response <- POST(handle = handle, path = path, body = login) #tried both of these test <- read_xml(response) test <- readHTMLTable(content(response, "text"))
Response evaluates to the following, which makes it seem as though it was successful, but the redirect URL doesn't seem to work and I don't actually get the list content:
Show in New WindowClear OutputExpand/Collapse Output
Date: 2018-09-04 20:17
Content-Type: application/soap+xml; charset=utf-8
Size: 1.37 kB
I've found a few articles that seem to have worked for people to authenticate to SP and pull data but those code bits haven't worked (and I've tried a lot of combos of that code). Do I need to do something with OAuth or have something set on the SP site itself. I feel like I'm close and I am also approaching the giving up point, any insights or thoughts would be appreciated.