Monday, July 4, 2016

Visual Studio Code Extension–SPRemoteAPI (SharePoint Office 365 REST API Discovery for the Masses)

Technorati Tags: ,,,

For everyone who has ever used the Visual Studio extension SPRemoteAPIExplorer one of the pain points is the requirement that you had have SharePoint installed on the same box as Visual Studio. Now you can get the same basic functionality of being able to browse and discover what is available in SharePoint and Office 365 REST and JavaScript API without having to have SharePoint installed. You can type in a namespace and browse the methods and properties. You can determine if they are available to be used with REST and JavaScript. You can also see what is new in SharePoint 2016. Finally when looking at specific methods or functions the extension gives the required POST bodies and response payloads, allowing the developer to easily copy and paste this into his code. You can get the VSCode extension here SPRemoteAPI in the Visual Studio Market Place. Oh did I mention it is FREE.

Using SPRemoteAPI Extension (Step 1)

In VSCode just hit F1 and start typing SPRemoteAPI and you will see it appear in the drop down list.


Using SPRemoteAPI Extension (Step 2)

After selecting the SPRemoteAPI command you will be presented with all the available types in the SharePoint Office 365 remote API. You can start typing and the list will automatically filter as you type. The example below shows typing “move” and the list is filtered down to types with the word move contained in them. This list shows a github icon (flame) next to types that are new in SharePoint 2016. It also lists whether the type can be used in REST or JavaScript. Some types are not available for both.

Using SPRemoteAPI Extension (Step 3)

Once you selected the type you are presented a information dialog showing you the type along with options for displaying properties and methods. The options also shows you the number of each contained in the type.

Using SPRemoteAPI Extension (Step 4)

Select the methods options and you are presented a list of available methods to choose from.

Using SPRemoteAPI Extension (Step 5)

Choose a method and a new code window (virtual document) opened containing a JSON representation of all the method’s information needed to call it remotely using REST. It shows you the parameter types, required post body and response body. The post body can be copied into whatever REST calling framework you are using such as FETCH or JQuery. The response can be used to guide you in what to expect in the payload response from the call. This gives you ability to write remote REST calls without having to do all the extra experimentation to see what the call returns. Having both the body and response JSON templates will save you a lot of time searching on the internet.

What about properties?

Below is example of the code window you are given when you select properties. It shows you all the available properties for the type and the information you need to determine what is available remotely from SharePoint Office 365.

SPRemoteAPI in Action


SPRemoteAPI VSCode Extension – SharePoint Office 365 REST Discovery at your fingertips

This Visual Studio Code extension was created to open up the SharePoint Office 365 remote API to the many developers who do not use Visual Studio to develop. This extension will run on non-windows environments and of course does not require SharePoint to be installed locally. You can now easily figure out what is available and how to call any SharePoint REST API without having to search and page through mounds of documentation. Enjoy being productive!

Thursday, March 31, 2016

Understanding SharePoint 2016 Remote API Changes (SPRemoteAPIExplorer 3.0)

Technorati Tags: ,,,

Well SharePoint 2016 has been released and you have no clue what new features are available from the remote API. There are a total 250 new types you can use and changes to an existing 86 types. This results in thousands of new properties and methods that are undocumented. You can now get started on understanding the changes with the updated SPRemoteAPIExplorer 3.0 Visual Studio extension. I have used this extension for years to find and discover new methods to call in the SharePoint 2013 remote API. If you have used it before you will know it can generate the Ajax REST method calls for you, create JSON for REST responses and payloads or create JSON object paths for deeply nested responses. Version 3.0 now gives you the ability to switch between SharePoint 2013 and SharePoint 2016 remote API’s. It also surfaces the complex types that are used as parameters and responses, this will give you a better understanding of the wide range of types that you need to know to code effectively against SharePoint On-Premises or Online. Finally, it gives you an option to see just the types that are new or have changed, which will make it easy to see and discover some of the great things that may make your coding life easier. Remember that the SharePoint 2016 remote API applies to both On-Premises and Online, but some methods may work only in SharePoint Online.

Easily Identify Remote API changes in SharePoint 2016

To easily find the new changes right click the top node to see the main context menu and select the “View only new and changed” menu item.

After clicking this menu item the explorer tree only shows types that are new or types that have changes. All new and changed features are identified with a “red dot” in their icons.

Show Complex Types used in the Remote API

Clicking the “Show complex types” menu item will load all the complex types into the explorer. Typically these types are used as parameters and responses and contain no methods.

Discover if Methods are supported by REST

Remember that you can click on a method or any node and discover it’s capabilities. If you click on a method and view its properties you can see if the method is supported for REST, CSOM or JSOM.

Generate Ajax code for Methods

If you select the “Create $ajax call” context menu item for a method it will copy all the code including the JSON payload for the REST call into the clipboard. You can then copy and paste this into your code. You can also generate the JSON and response paths for method responses.

Visions for Visual Studio Code

There have been past complaints that this extension is dependent upon SharePoint being installed locally. SPRemoteAPIExplorer 3.0 is dependent only upon Visual Studio Office Tools, but the extension relies on the “SharePoint Server Explorer” tool to surface the API nodes. Unfortunately, this explorer will only work with SharePoint being installed. So I am currently working on a VS Code extension to surface this information. Unfortunately, it will not be as full featured as this extension but it will allow other developers to access this information. Another option would be to expose this information as a service.

Time to Catch Up on your API

SharePoint 2016 is released so you better start catching up. I hope this new extension will help you do that and become more productive. I plan on keeping this up to date as API changes are pushed to On-Premises. It would be nice to be able to get this information from O365 instead of waiting for the On-Premises push. Enjoy.