# Sharepoint app

1. In a Web Browser open Graph Explorer (<https://developer.microsoft.com/en-us/graph/graph-explorer>) and log in as someone who has the necessary privileges to create/modify sharepoint access permissions.
2. Execute the following GET request, replace '' with the name of your site, leave the body empty...

```
https://graph.microsoft.com/v1.0/sites?select=webUrl,Title,Id&$search="<site-name>"
```

You should see something like this - make a note of the value.id property (the 'site id') as you'll need it later...

```
{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites",
    "value": [
        {
            "id": "XXX.sharepoint.com,XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX,XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
            "webUrl": "https://XXX.sharepoint.com/sites/SiteName",
            "displayName": "SiteName"
        }
    ]
}
```

3. We now need to make a POST request (though this time we need to put something in the body) to give the above application permissions to read and write to the site, via an URL like this (replacing '' with the 'site id' you made a note of above)...

```
https://graph.microsoft.com/v1.0/sites/<site-id-from-above-GET-request>/permissions
```

So for the above site for example, the URL would look like this...

> <https://graph.microsoft.com/v1.0/sites/XXX.sharepoint.com,XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX,XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/permissions>

...with this as the body, changing XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX to the 'application (client) id' you made a note of earlier in step 7...

```
{
    "roles": [
        "manage"
    ],
    "grantedToIdentities": [
        {
            "application": {
                "id": "ad916092-4fef-492d-80ac-31b34e96f2de",
                "displayName": "Omnidesk Assistant Sharepoint"
            }
        }
    ]
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.omnidesk.io/omnidesk/sharepoint-app.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
