user19233
user19233

Reputation: 1

Access sharepoint list from web site hosted externally from sharepoint

I'm developing a web application externally from sharepoint online 2010. As part of the application I would like to allow users to access documents from a document library. Ideally users would click on an option, this would query the library for documents, and return a JSON object for each object satisfying the query for display as links in a webpage.

I've been looking for a way to do this in a website hosted externally from sharepoint 2010, but I have been unable to find resources describing how to load the ECMA script API and connect to a sharepoint site. Does anyone know where I can find this information?

Thank you for your help!

Upvotes: 0

Views: 6960

Answers (1)

Gonzix
Gonzix

Reputation: 1206

You have several ways to achieve this. The out of the box option would be using queries (from server code or ajax) your list SVC. In case you don't know, all lists have an associated service to pull information.

  1. http://msdn.microsoft.com/en-us/library/hh134614(v=office.14).aspx
  2. http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/01/21/introduction-to-querying-lists-with-rest-and-listdata-svc-in-sharepoint-2010.aspx

There is a wonderful js library at codeplex, spservices, that helps you to query your sharepoint. With this list you could do something like this (sample code taken from codeplex samples)

<script language="javascript" type="text/javascript">

$(document).ready(function() {
  $().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "Announcements",
    CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>",
    completefunc: function (xData, Status) {
      $(xData.responseXML).SPFilterNode("z:row").each(function() {
        var liHtml = "<li>" + $(this).attr("ows_Title") + "</li>";
        $("#tasksUL").append(liHtml);
      });
    }
  });
});
</script>

More information at http://spservices.codeplex.com/wikipage?title=GetListItems? Keep in mind if the list has security restrictions you will run into pretty "interesting" authetication issues as you are running this calls outside sharepoint and it will not know who the hell is making the calls. So, just as a suggestion, consider running your pages under sharepoint.

Upvotes: 2

Related Questions