Things hard and not so hard.... RSS 2.0
# Monday, February 11, 2013

After wrestling with this tonight for sometime I’ve finally cracked it. SP2013 RTMed and alot of the sample code fails due to the fact that you need to now add ‘..;odata=verbose’ onto pretty much every call to SharePoint.

Basically you get a series of errors such as:

MIME type could not be found that matches the content type of the response. None of the supported type(s) 'application/atom+xml;type=entry, application/atom+xml, application/json;odata=verbose

 

Previously alot of the sample code has

$.getJSON(….) as part of the call to the server – as mentioned we now need to add some custom header values of ‘odata=verbose’, so to save you hours of slogging on this, the getJSON call doesn’t allow custom header values. You need to use the $.ajax(…) for these calls.

READING FROM A LIST

function getCustomers() {
 

  // begin work to call across network
  var requestUri = _spPageContextInfo.webAbsoluteUrl +
                "/_api/Web/Lists/getByTitle('CustomersREST')/items/" +
                "?$select=Id,FirstName,Title,WorkPhone" +
                "&$orderby=Title,FirstName";
   
  var requestHeaders = {
      "accept": "application/json;odata=verbose"
  }
    // execute AJAX request
  $.ajax({
      url: requestUri,
      type: 'GET',
      dataType: 'json',
      headers: requestHeaders,
      success: onDataReturned,
      error: onError
  });
}

 

UPDATING A LIST ITEM

//Sample code to update a Customer List Item in a Customer List called ‘CustomersREST’

function updateCustomer(dialogResult, returnValue) {

  if (dialogResult == SP.UI.DialogResult.OK) {
    var Id = returnValue.Id;
    var FirstName = returnValue.FirstName;
    var LastName = returnValue.LastName;
    var WorkPhone = returnValue.WorkPhone;
    var etag = returnValue.etag;

    var requestUri = _spPageContextInfo.webAbsoluteUrl +
              "/_api/Web/Lists/getByTitle('CustomersREST')/items(" + Id + ")";

    var customerData = {
      __metadata: { "type": "SP.Data.CustomersRESTListItem" },
      Title: LastName,
      FirstName: FirstName,
      WorkPhone: WorkPhone
    };

    requestBody = JSON.stringify(customerData);

    var requestHeaders = {
        "accept": "application/json;odata=verbose",
        "X-RequestDigest": $("#__REQUESTDIGEST").val(),
        "X-HTTP-Method": "MERGE",
        "content-length": requestBody.length,
        "content-type" : "application/json;odata=verbose",
        "If-Match": etag
    }

    $.ajax({
      url: requestUri,
      type: "POST",
      contentType: "application/json;odata=verbose",
      headers: requestHeaders,
      data: requestBody,
      success: onSuccess,
      error: onError
    });

  }

}

Monday, February 11, 2013 10:47:06 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0] -
.NET Developer | SharePoint | 2013 | Tips
# Thursday, February 07, 2013

While setting up a new SharePoint solution one of the requirements was to embed a Yammer Feed.

So I followed the help document only to have an unusual situation:

1) the feed wouldnt render in browse mode.

2) the feed WOULD render in Edit Mode.

The key to the situation was to declare a little more on the sample script Yammer gave – adding ‘text/javascript’

Here’s the working script – (one for the bat –utility belt)

*tested from Win8, Firefox *

<script data-app-id='hyB2pTvrL36Y50py8EWj6A' type='text/javascript' src='https://assets.yammer.com/platform/yam.js'></script>
<script type='text/javascript'>
yam.connect.embedFeed(
{ container: '#embedded-feed'
, network: 'yournetworkhere'
});
</script>
<div id='embedded-feed'></div>

Thursday, February 07, 2013 11:41:39 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0] -
.NET Developer | 2013 | Tips
# Tuesday, November 20, 2012

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 Hosted…depending 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)

 

Table 1. SPContextWebInformation structure initialization properties

Property

Description

webFullUrl

Gets the server-relative URL of the nearest site.

siteFullUrl

Gets the server-relative URL of the root of the site collection that the site is contained within.

If the nearest web is the root of a site collection, then the value of the webFullUrl property is equal to the siteFullUrl property.

formDigestValue

Gets the server's request form digest.

LibraryVersion

Gets the current version of the REST library.

SupportedSchemaVersions

Gets the versions of the schema of the REST/CSOM library that are supported.

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.

Tuesday, November 20, 2012 3:43:32 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0] -
Dev | SharePoint | 2013 | Tips
# Tuesday, November 13, 2012

Hi folks, I’m just blown away by all the goodies in these 2 releases

1) the SP1

2) the Feature Pack SP1

Both have some pretty big improvements, especially around the SharePoint 2013 <-> SQL scenario and pivot tables, analysis, mining etc.

There’s even SQL Services that continuously copy data from Oracle to SQL – this I’ll have to try on my next BizTalk project.

Check it out - http://www.microsoft.com/en-us/download/details.aspx?id=35580

Now I’d love to have a single download for them all…. Smile

Tuesday, November 13, 2012 10:17:18 PM (AUS Eastern Daylight Time, UTC+11:00)  #    Comments [0] -
BizTalk | General | SharePoint | 2013
Archive
<July 2014>
SunMonTueWedThuFriSat
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789
Blogroll
 AppFabric CAT
AppFabric Windows Server Customer Advisory Team - New Blog.
[Feed] BizTalk 2006 - Windows SharePoint Services adapter
BizTalk 2006 Sharepoint adapter!!
 Breeze SharePoint 2010 Bootcamp
Breeze SharePoint 2010 Bootcamp
[Feed] BTS 2006 R2/EDI
[Feed] Chris Vidotto (MS BTS Legend)
Needs no intro....
 Mark Daunt
BTS/SPS/.NET GURU!!!
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2014
Breeze
Sign In
Statistics
Total Posts: 603
This Year: 7
This Month: 0
This Week: 0
Comments: 270
All Content © 2014, Breeze