Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use and Access Site Lists #17

Open
s7clarke10 opened this issue May 26, 2023 · 2 comments
Open

Use and Access Site Lists #17

s7clarke10 opened this issue May 26, 2023 · 2 comments

Comments

@s7clarke10
Copy link

s7clarke10 commented May 26, 2023

Hi,

This tap looks like it can be very handy to obtain a SharePoint List, however I'm not quite sure how I could do this.

I can't access this URL at my workplace:
https://graph.microsoft.com/v1.0/groups

But I can access this to get the content of the SharePoint List.

https://graph.microsoft.com/v1.0/sites/{SiteID}/Lists/{ListID}/items/?expand=fields

This call will return the contents of the List which I will need to paginate through the items in it.

Having a look at the code I have a feeling that I need to add the following code to access sites.

streams.py

class SitesStream(MSGraphStream):
    name = "sites"
    path = "/sites"
    primary_keys = ["id"]
    odata_context = "sites"

tap.py

from tap_ms_graph.streams import (
    GroupMembersStream,
    GroupsStream,
    SubscribedSkusStream,
    SitesStream,
    UsersStream,
)

STREAM_TYPES = [
    GroupsStream,
    GroupMembersStream,
    SubscribedSkusStream,
    SitesStream,
    UsersStream,
]

However when I run the following Meltano command meltano select tap-ms-graph --list, I can't see any Sites available to select. I would like to add some enhancements to access SharePoint Lists but not sure if I am heading in the right direction or not.

Any advice would be much appreciated as I need to ingest several SharePoint Lists.
Thanks

@robby-rob-slalom
Copy link
Collaborator

Hey @s7clarke10,

I had a chance to look into this and the /sites endpoint appears to only work with application permissions and shows root sites across geographies (see here). Try /sites/root or /sites/{site_id} (or /sites/{site_id}/sites for subsites).

To get to the lists of a site, there would need to be a way to get the {site_id} to a stream endpoint /sites/{site_id}/lists.

Here is an example of adding two streams and chaining them together:

class SiteRootsStream(MSGraphStream):
    name = "siteRoots"
    path = "/sites/root"
    records_jsonpath = "$"
    primary_keys = ["id"]
    odata_context = "sites/$entity"
    child_context = {"id": "site_id"}

class SiteListsStream(MSGraphChildStream):
    parent_stream_type = SiteRootsStream
    name = "siteLists"
    path = "/sites/{site_id}/lists"
    primary_keys = ["site_id", "id"]
    odata_context = "sites/lists"

    parent_context_schema = {
        "site_id": {"type": "string"},
    }

The odata_context and other settings may need to be adjusted for the schema to work.

@s7clarke10
Copy link
Author

s7clarke10 commented Jul 4, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants