├── README.md └── SharePointRESTtester.html /README.md: -------------------------------------------------------------------------------- 1 | # SharePointRESTtester 2 | A JavaScript project to use with a Content Editor Web Part to test SharePoint REST API calls. It also creates AJAX sample code and SharePoint Designer 2013 Workflow steps. 3 | 4 | Screen captures and a detailed install can be found at: http://techtrainingnotes.blogspot.com/2017/04/a-sharepoint-rest-api-tester-with-ajax.html 5 | 6 | Now has over 80 SharePoint REST API examples! (see list below) 7 | 8 | To use: 9 | --------- 10 | 11 | 1. If your master page is not already loading jQuery, download jQuery (just about any version) and upload to the Site Pages library. 12 | 2. Download the SharePointRESTtester.html file to your PC. 13 | 3. Edit the file and update the line that loads jQuery to point your jQuery file. If your master page already loads jQuery, then delete the <script> block that loads the jQuery file. (the first line of the file) 14 | 4. Upload the SharePointRESTtester.html file to your Site Pages library. (Copy the URL to the file.) 15 | 5. Add a Web Part Page to your project: 16 | 5.1 In the Site Pages library, click the **FILES** ribbon, click **New Document** and click Web **Part Page**. 17 | 5.2 Enter a page name like "SharePointRESTtester". 18 | 5.3 From the library dropdown select **Site Pages**. 19 | 5.4 Click Create. 20 | 6. Click **Add a Web Part**. 21 | 7. Add a Content Editor Web Part. 22 | 8. Click the web part's dropdown and click **Edit Web Part**. 23 | 9. Enter or paste the path to the SharePointRESTtester.html file. 24 | 10. Click **OK** and then in the ribbon click **Stop Editing**. 25 | 11. You should now see the tester. Click the dropdown and you should see data in the boxes. If not, then the jQuery library did not get loaded. 26 | 27 |

28 | 29 | **Examples included** 30 | 31 | **Search Queries (/_api/search/query)** 32 | 33 | - Keyword Search 34 | - Keyword Search with refinement filters (this one for file type) 35 | - Keyword Search with OR'd refinement filters (ANDs are similar) 36 | - People Search 37 | - List of all Site Collections for current user using search (No direct REST API). 38 | - List of all Web Sites for current user using search (No direct REST API). 39 | 40 | **Misc REST Queries** 41 | 42 | - Get SharePoint's list of Time Zones. 43 | - Get Context info. 44 | 45 | **CAML Queries** 46 | 47 | - CAML Query to find documents by Created date. 48 | - CAML Query to return all folders in a library. Uses FSObjType=1 and CAML recursive. 49 | 50 | **List items and documents** 51 | 52 | - Get a count of items in a library. 53 | - Get a count of items in a library. (Option #2) 54 | - Get all items in a list/library. 55 | - Get all items in a library with filename and path. 56 | - Get a list/library item by property and display the Title. 57 | - Get info about list attachments. 58 | - Get info about a single list attachment. 59 | - Get a library item by Filename and display the Title and ID. 60 | - Get a list/library item by ID and display the Title. 61 | - Get all items in a list/library filtered by date. 62 | - Add a new item to a list 63 | - Delete an item from a list using ID 64 | - Delete an item from a list using its URL 65 | - Delete an item, to the Recycle Bin, from a list using ID 66 | - Update an item using ID 67 | - Download a file. 68 | 69 | **Folders** 70 | 71 | - CAML Query to return all folders in a library. Uses FSObjType=1 and CAML recursive. 72 | - Get a list folder's properties. 73 | - Get a count of items in a list folder. 74 | - Add a folder 75 | - Rename a folder 76 | 77 | **Lists** 78 | 79 | - Get a list of lists from the current web. (all data) 80 | - Get a list of lists from the current web. (Just the title) 81 | - Get a list of Content Types for the current web. 82 | - Get a list of list columns. (Title,InternalName,FieldTypeKind,Formula,Hidden,Indexed) 83 | - Get a list of list columns by type. This one returns Calculated Columns. 84 | - Create a new list 85 | - Add a new folder to a list 86 | - Delete a list 87 | - Delete a list to the Recycle Bin 88 | 89 | **Recycle Bins** 90 | 91 | - Get all items in web level recycle bin. 92 | - Get selected properties of all items in web level recycle bin. 93 | 94 | **Site Collections** 95 | 96 | - Get information about the current site collection. 97 | - Get the size of the content in the current site collection. 98 | - Get the primary site collection administrator (Owner). 99 | - Get the primary site collection Secondary Contact. 100 | 101 | **Webs (subsites)** 102 | 103 | - Get information about the current web. 104 | - Get the Regional Settings for the current web. 105 | - Get the Time Zone for the current web. 106 | - Get a list of all webs below the current web. 107 | - Get a list of all webs below the current web using "webinfos". 108 | - Get a web's LastItemModifiedDate 109 | - Create a new subsite. 110 | - Delete a site (Warning Will Robinson! Does not go to the Recycle Bin!) 111 | 112 | **User Profiles** 113 | 114 | - Get User Profile info about the current user. 115 | - Get all User Profile properties for a user. 116 | - Get User Profile info about a user's manager. (Set "propertyName=" to any User Profile Services property.) 117 | 118 | **Permissions** 119 | 120 | - Get a list of Role Definitions for a site. 121 | - Get a list of Site Users. The ID is useful when setting permissions. 122 | - Get a list of Site Groups. The ID is useful when setting permissions. 123 | - Get a list of Site Groups by name (filter). 124 | - Get info about a Site Group using the ID. 125 | - Get info about a Site Group using the Name. 126 | - Get a list of users in a Site Group. 127 | - Get a user by id from a Site Group. 128 | - Get a user by email address from a Site Group by ID. 129 | - Get a user by email address from a Site Group by Name. 130 | - Get a user by partial email address from a Site Group by Name. 131 | - Add a user to a Site Group by login name. 132 | - Remove a user from an Site Group by user ID. 133 | - Get a list of Site Groups where name contains 'string'. 134 | - Break inheritance on a subsite. 135 | - Break inheritance on a list. 136 | - Break inheritance on a list item. 137 | - Grant permissions (Role Assignment) on a list. 138 | - Remove permissions (Role Assignment) on a list. 139 | 140 | **Filter Select and OrderBy** 141 | 142 | - Get a list of Site Users who are not Site Collection admins. Get selected fields and sort. 143 | 144 | **SharePoint 2010 style REST - _vti_bin/ListData.svc** 145 | 146 | - Get a list of lists and libraries (EntitySets). 147 | - Find list items greater than a date. 148 | - Find list items between two dates. 149 | -------------------------------------------------------------------------------- /SharePointRESTtester.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 252 | 253 | 254 | 275 | 276 | 277 | 278 | 279 |
280 | 281 |

SharePoint 2013 and later REST Tester! (SharePointRESTtester)


282 | This tool is used to build and test the REST API for SharePoint 2013 and later. It currently only supports JSON data and not XML.
283 | For info see Tech Training Notes blog or GitHub. 284 | SharePoint REST metadata from your farm.

285 | 286 | 296 | 297 | Select a sample from this list, or add your URL and JSON to test.
298 | 1072 | 1073 | 1074 | 1075 |
1076 | Notes:
1077 |
 
1078 |
1079 | 1080 | 1081 | 1082 | 1083 | 1086 | 1087 | 1088 |
URL:
Method:
1084 | ODATA options: odata=verbose, odata=nometadata, odata=minimalmetadata 1085 |
Headers:
Body:
Must use single quotes!
1089 | 1090 | 1091 | 1092 | 1093 | 1094 | 1095 |

1096 | Call the web service and run the code!
1097 | Show the AJAX Code
1098 | Show the workflow steps
1099 | 1100 | 1101 | 1102 | 1103 |


1104 | 1105 | 1106 | 1107 | 1108 | 1109 | 1236 | 1237 |



1238 | 1239 | 1240 | 1241 | 1242 | 1303 | 1304 | --------------------------------------------------------------------------------