Skip to content

Instantly share code, notes, and snippets.

@jwstl
Last active March 6, 2023 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwstl/0f8c68d1bf5192035b9e7196fd843141 to your computer and use it in GitHub Desktop.
Save jwstl/0f8c68d1bf5192035b9e7196fd843141 to your computer and use it in GitHub Desktop.
O365 SharePoint

Site Permissions:

METHOD: POST

HTTP REQUEST: https://graph.microsoft.com/v1.0/sites/{site-id}/permissions

REQUEST BODY:

{
  "roles": ["write"],
  "grantedToIdentities": [
    {
      "application": {
        "id": "b6453650-96ff-4a78-b1bb-d2f538cc5e5d",
        "displayName": "Service Now Testing"
      }
    }
  ]
}

REQUEST RESPONSE: Created 201

REQUEST RESPONSE BODY:

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('ff7c26f2-fe40-4be3-9104-f67b9aac8eb7')/permissions/$entity",
  "id": "aTowaS50fG1zLnNwLmV4dHxiNjQ1MzY1MC05NmZmLTRhNzgtYjFiYi1kMmY1MzhjYzVlNWRAOTI4OTZjZjctMDI4NC00OTE2LTkwNjktNGVlMDA1OWYyMmRl",
  "roles": ["write"],
  "grantedToIdentitiesV2": [
    {
      "application": {
        "displayName": "Service Now Testing",
        "id": "b6453650-96ff-4a78-b1bb-d2f538cc5e5d"
      }
    }
  ],
  "grantedToIdentities": [
    {
      "application": {
        "displayName": "Service Now Testing",
        "id": "b6453650-96ff-4a78-b1bb-d2f538cc5e5d"
      }
    }
  ]
}

LIST OPERATIONS

Get Lists in Site:

METHOD: GET

HTTP REQUEST: https://graph.microsoft.com/v1.0/sites/{site-id}/lists

REQUEST BODY: N/A

REQUEST RESPONSE: 20O OK

REQUEST RESPONSE BODY:

Get List Items:

METHOD: GET

HTTP REQUEST: https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items?expand=fields(select=Column1,Column2)

REQUEST BODY: N/A

REQUEST RESPONSE: 20O OK

REQUEST RESPONSE BODY:

Create List:

METHOD: POST

HTTP REQUEST: https://graph.microsoft.com/v1.0/sites/{site-id}/lists

REQUEST BODY:

Content-Type: application/json

{
  "displayName": "Books",
  "columns": [
    {
      "name": "Author",
      "text": { }
    },
    {
      "name": "PageCount",
      "number": { }
    }
  ],
  "list": {
    "template": "genericList"
  }
}

REQUEST RESPONSE: 201 Created REQUEST RESPONSE BODY:

HTTP/1.1 201 Created
Content-type: application/json

{
  "id": "22e03ef3-6ef4-424d-a1d3-92a337807c30",
  "createdDateTime": "2017-04-30T01:21:00Z",
  "createdBy": {
    "user": {
      "displayName": "Ryan Gregg",
      "id": "8606e4d5-d582-4f5f-aeba-7d7c18b20cfd"
    }
  },
  "lastModifiedDateTime": "2016-08-30T08:26:00Z",
  "lastModifiedBy": {
    "user": {
      "displayName": "Ryan Gregg",
      "id": "8606e4d5-d582-4f5f-aeba-7d7c18b20cfd"
    }
  }
}

Create List Item: METHOD: POST HTTP REQUEST: https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items REQUEST BODY:

Content-Type: application/json

{
  "fields": {
    "Title": "Widget",
    "Color": "Purple",
    "Weight": 32
  }
}

REQUEST RESPONSE: 201 Created REQUEST RESPONSE BODY:

HTTP/1.1 201 Created
Content-type: application/json

{
  "id": "20",
  "createdDateTime": "2016-08-30T08:26:00Z",
  "createdBy": {
    "user": {
      "displayName": "Ryan Gregg",
      "id": "8606e4d5-d582-4f5f-aeba-7d7c18b20cfd"
    }
  },
  "lastModifiedDateTime": "2016-08-30T08:26:00Z",
  "lastModifiedBy": {
    "user": {
      "displayName": "Ryan Gregg",
      "id": "8606e4d5-d582-4f5f-aeba-7d7c18b20cfd"
    }
  }
}

Update List Item: METHOD: POST HTTP REQUEST: https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id} REQUEST BODY:

Content-Type: application/json

{
    "Color": "Fuchsia",
    "Quantity": 934
}

REQUEST RESPONSE: 200 OK REQUEST RESPONSE BODY:

HTTP/1.1 200 Ok
Content-type: application/json

{
  "Name": "Widget",
  "Color": "Fuchsia",
  "Quantity": 934
}

Delete List Item: METHOD: DELETE HTTP REQUEST: https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id} REQUEST BODY: N/A REQUEST RESPONSE: 204 No Content REQUEST RESPONSE BODY:

HTTP/1.1 204 No Content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment