While on SharePoint 2013 training we came across all the different ways of calling
SharePoint and it’s data through JavaScript, JQuery and all the bits.
It was all looking good until we needed to update sharepoint – e.g.
a list, a list item etc.
The MS Course notes say – “if you’re in SharePoint you can get the Form Digest from
the main SharePoint Form.”
What about if you’re running outside of SharePoint (a Provider App – they now call
it, or Cloud Hosteddepending on who wrote the help article)
The answer in the notes is go and make an old fashion call to Sites.asmx
SOAP WebService. from client side javascript this is going to be a feat.
.
The Answer – make a REST call to get the ’Context Info’ first, then
you’ll have the form digest and you’re done.
http://msdn.microsoft.com/en-us/library/fp142386(office.15).aspx#bk_synchronize (just
at the top of this page)
1. SPContextWebInformation structure initialization properties
Property |
Description |
---|---|
webFullUrl |
Gets the server-relative URL of |
siteFullUrl |
Gets the server-relative URL of
If the nearest web is the root |
formDigestValue |
Gets the server’s request form |
LibraryVersion |
Gets the current version of the |
SupportedSchemaVersions |
Gets the versions of the schema |
To access this information, use
the /contextinfo operator.
For example:
http://server/web/doclib/forms/_api/contextinfo
To increase security against
cross-site scripting attempts, the /contextinfo operator
accepts only POST requests.
Blog Post by: Mick Badran