In this article we will understand how utilize a famous developer productivity tool called fiddler as REST API Test Client for SharePoint (though the target system could be anything with a valid REST API Endpoint)
Fiddler is primarily used as a Web Proxy that can allow you intercept REST API Request – Response Cycle. The usage of this tool has increase with shift in modern SharePoint development paradigms that favors more if Client Side Development Techniques/Strategies/Platforms rather than traditional Farm Solutions.
In this upcoming section of this article I will guide on how to use Fiddler to test REST API Call against SharePoint Data.
In this article we will explore only GET type of Requests only.
To start with this demo launch Fiddler and go to “Rules” Menu and Select “Automatically Authenticate”, this will let Fiddler to authenticate you against SharePoint based on the User Token stored once.
If this setting is not enabled you might encounter “401 UNAUTHORIZED” as shown below-
Also notice the request headers that are required to execute the SharePoint REST API Endpoint
http://<Host Name>/_api/<SharePoint Endpoint>
Request Headers Accept: application/json;odata=verbose Content-Type: application/json;odata=verbose
Get Web Object
- Click on “Compose” Tab
- Select request type as “GET” from dropdown
- Specify the Request URL as http://<Host Name>/_api/web
- Click on “Execute” Button
Once the request is issued using Fiddler “Composer“, we can see the request details in the left pane
When you click on the request in the left pane we can see the details breakdown in the Right Pane
For instance we can click on “Inspectors” tab and then click on “JSON” tab.
JSON Tab will display the response received from SharePoint in JSON Format.
Similarly we can execute other GET Requests as shown in upcoming Screen Shots-
Get List Object
Get Lists which are not hidden and have Items
http://<Host Name>/_api/Web/Lists?$select=Title,Hidden,ItemCount&orderby=ItemCount&$filter=((Hidden eq false) and (ItemCount gt 0))
Encoded Version of Request URL
Get Web filtered by Title
Get Web and Lists using Look Properties Expanding Lists Collection
Get Web and Lists using Look Properties Expanding Users Collection
That is all for this demo.
Hope you find it helpful.