So what does REST on Excel Services look like???


In my first post about Excel Services and REST, I showed how to construct a simple REST URL pointing directly to a PNG in a workbook. This post was supposed to be about the discovery built into the Excel Services REST API. However, I got a couple of questions about what my previous post actually looks like visually when used inside SharePoint 2010 and so I decided to post about that today instead. People like shiny screenshots.. 🙂


In the previous post, I gave the following example of a REST URL:


http://server/_vti_bin/ExcelRest.aspx/Shared Documents/Bugs.xlsx/Model/Charts(‘PersonalBugChart’)

In this post, I will show how a similar URL is used to post a chart about my alleged bug status into a SharePoint blog and have the chart be tied directly to the Excel file in which it resides.

First off – here’s what the chart looks like in Excel:

image

If you click the image you will see that the chart is called “PersonalBugs”. The actual location of the file is at “http://tssrva/sites/sp2009/shared documents/bugs.xlsx”. That means that the link to the chart inside Excel would be:

http://tssrva/_vti_bin/ExcelRest.aspx/sites/sp2009/shared documents/Bugs.xlsx/Model/Charts(‘PersonalBugs’)

The next step would be to create a blog post in SharePoint – when creating the blog entry, you can choose the “Insert” tab from the ribbon and then choose “From Address”:

image

Once you click address, all you need to do is put in the URL to the chart:

image

Once you hit OK, you will immediately see the chart appear within the blog post editor:

image

Hitting the Submit button will post the blog entry:

image

The real neat part then becomes that as the workbook changes (due to external data being refreshed, the spreadsheet itself being modified and saved etc), everybody will see the changes directly on the blog the next time they come in!

I hope the shiny screenshots made everything clearer.

Next up: Discovery!!

Comments (6)

  1. Oren says:

    realy nice

    how does security works in this case, is REST supports integrated windows authentication

  2. Shahar Prish says:

    Yes, it supports Windows auth.

  3. Hassan says:

    I didn’t get this, can you tell us more about how or where to set permisions for REST, and how is the sharepoint security reflected there.

    Regards

  4. Shahar Prish says:

    There’s no need to set permissions – it will work out of the box.

    SharePoint security is reflected just like any other resource  – if you do not have access to the file, you will not be able to access the REST portion of it.

  5. Shreya Agarwal says:

    hey, the URL works from the browser, but when I try and access it from inside my C# code I get an "Unauthorized" error. Any way to authorize this URL access from inside C#? I have a username and pass.

  6. Hi Shahar,

    This is *really* nice and I'm annoyed that I'm only exploring the REST API today, more than two years after it came out.

    I do have some feedback though:

    1) Those URIs aren't very clean. "_vti_bin", "ExcelRest.aspx"…are they really necessary? Please, in the future, could you provide something like this: http://server/Shared Documents/Bugs.xlsx/Model/Charts(‘PersonalBugChart’). That URI provides the necessary addressability and is a lot easier to remember.

    2) Discoverability of these resources is not easy, we essentially have to handcrank a URI ourselves. Take your example here of embedding a chart into a blog post – would it not be better if I could browse first through the document library to an Excel workbook and THEN through the workbook to the chart/range/table that I am interested in? Call it a wizard if you like. That would be really cool and would, I am sure, promote this feature and cut down on the copy-and-paste disease that the REST API is meant to alleviate.

    great stuff, thanks.

    jt