Sharepoint 2010 Discussion Board using REST service

November 10, 2012 Leave a comment

This post address about accessing sharepoint 2010 discussion board using listdata.svc

i)Creating new discussion

<?xml version=”1.0″ encoding=”utf-8″ standalone=”yes”?>
<entry xmlns:d=”http://schemas.microsoft.com/ado/2007/08/dataservices” xmlns:m=”http://schemas.microsoft.com/ado/2007/08/dataservices/metadata” xmlns=”http://www.w3.org/2005/Atom“>

<category scheme=”http://schemas.microsoft.com/ado/2007/08/dataservices/scheme” term=”Microsoft.SharePoint.DataService.TeamDiscussionItem” />
  <title type=”text”>Hello REST</title>
  <updated>0001-01-01T00:00:00Z</updated>
  <author>
    <name />
  </author>
  <id />
  <content type=”application/xml”>
    <m:properties>
      <d:Body m:null=”true” />
      <d:ContentType>Discussion</d:ContentType>
      <d:ContentTypeID>0x0120</d:ContentTypeID>
      <d:Created m:type=”Edm.DateTime”>2012-07-18T20:42:56.7959323-07:00</d:Created>
      <d:CreatedById m:type=”Edm.Int32″ m:null=”true” />
      <d:EMailSender m:null=”true” />
      <d:Id m:type=”Edm.Int32″>0</d:Id>
      <d:LastUpdated m:type=”Edm.DateTime” m:null=”true” />
      <d:Modified m:type=”Edm.DateTime” m:null=”true” />
      <d:ModifiedById m:type=”Edm.Int32″ m:null=”true” />
      <d:ModifiedById0 m:type=”Edm.Int32″ m:null=”true” />
      <d:Owshiddenversion m:type=”Edm.Int32″ m:null=”true” />
      <d:Path m:null=”true” />
      <d:Subject>REST request for new thread</d:Subject>
      <d:Version m:null=”true” />
    </m:properties>
  </content>
</entry>

ii)Reply to discussion

While replying to the existing thread need to make sure the Path consist of the title of the discussion

to which we are responding. Also the  content type attribute should be given as Message

<?xml version=”1.0″ encoding=”utf-8″ standalone=”yes”?>
<entry xmlns:d=”http://schemas.microsoft.com/ado/2007/08/dataservices” xmlns:m=”http://schemas.microsoft.com/ado/2007/08/dataservices/metadata” xmlns=”http://www.w3.org/2005/Atom“>
  <category scheme=”http://schemas.microsoft.com/ado/2007/08/dataservices/scheme” term=”Microsoft.SharePoint.DataService.TeamDiscussionItem” />
  <title type=”text”>Reply for REST request for new thread</title>
  <updated>0001-01-01T00:00:00Z</updated>
  <author>
    <name />
  </author>
  <id />
  <content type=”application/xml”>
    <m:properties>
      <d:Body>Reply for REST request for new thread</d:Body>>
      <d:ContentType>Message</d:ContentType>
      <d:ContentTypeID>0x0107</d:ContentTypeID>
      <d:Created m:type=”Edm.DateTime”>2012-07-18T20:42:56.7959323-07:00</d:Created>
      <d:CreatedById m:type=”Edm.Int32″ m:null=”true” />
      <d:EMailSender m:null=”true” />
      <d:Id m:type=”Edm.Int32″>0</d:Id>
      <d:LastUpdated m:type=”Edm.DateTime” m:null=”true” />
      <d:Modified m:type=”Edm.DateTime” m:null=”true” />
      <d:ModifiedById m:type=”Edm.Int32″ m:null=”true” />
      <d:ModifiedById0 m:type=”Edm.Int32″ m:null=”true” />
      <d:Owshiddenversion m:type=”Edm.Int32″ m:null=”true” />
      <d:Path>/<SITE>/Lists/Team Discussion/REST request for new thread</d:Path>
      <d:Subject>REST request for new thread</d:Subject>
      <d:Version m:null=”true” />
    </m:properties>
  </content>
</entry>

Advertisements

Sharepoint 2010 Discussion Board using SOAP service

November 10, 2012 2 comments

Accessing Read/Reply to the thread in Sharepoint Discussion board.

1) Using SOAP:

Folowing the soap request format to get read all the threads from discussion board

based on requested user permission.

<?xml version=”1.0″ encoding=”utf-8″?>
<soap:Envelope xmlns:soap=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema“>
<soap:Body>
<GetListItems xmlns=”http://schemas.microsoft.com/sharepoint/soap/“>
<listName>{46622757-67AC-4C9B-A715-69C46A8E6D96}</listName>
</GetListItems>
</soap:Body>
</soap:Envelope>

where,

–  <listName> is a GUID for the list extracted from list settings url.

To create a new discussion

<?xml version=”1.0″ encoding=”utf-8″?>
<soap:Envelope xmlns:soap=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema“>
<soap:Body>
<AddDiscussionBoardItem xmlns=”http://schemas.microsoft.com/sharepoint/soap/“>
<listName>{46622757-67AC-4C9B-A715-69C46A8E6D96</listName>
<message>TWVzc2FnZS1JRDogZmMxMjY1YzMtNzcxYi00MjkyLTg3ZDUtNjY2NGU3MTkyZTVhClRocmVhZEluZGV4OiA0NGFkYTZmOS0zNmFiLTQzNjAtOTM3ZC1hNDA0ODc4MmFkYTYKU3ViamVjdDogU09BUCBEaXNjdXNzaW9uCk1pbWUtVmVyc2lvbjogMS4wCkNvbnRlbnQtdHlwZTogdGV4dC9wbGFpbjsgY2hhcnNldD1VVEYtOA==</message>
</AddDiscussionBoardItem>
</soap:Body>
</soap:Envelope>

where,

<message>is base 64 encoded string for below mime type,

Message-ID: gc1265c3-772x-4292-87d5-6664e7192e5a
ThreadIndex: 43ada6f9-35bc-4360-937d-a4048782ada2
Subject: SOAP New Discussion
Mime-Version: 1.0
Content-type: text/plain; charset=UTF-8

Reply to existing discussion

<?xml version=”1.0″ encoding=”utf-8″?>
<soap:Envelope xmlns:soap=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema“>
<soap:Body>
<UpdateListItems xmlns=”http://schemas.microsoft.com/sharepoint/soap/“>
<listName>{46622757-67AC-4C9B-A715-69C46A8E6D96}</listName>
<updates>
<Batch RootFolder=”/<SITE>/Lists/Team Discussion/Soap Discussion” OnError=”Continue” xmlns=””>
<Method ID=”0″ Cmd=”New”>
<Field Name=”Body”>SOAP Reply</Field>
<Field Name=”ContentType”>Message</Field>
<Field Name=”DiscussionTitleLookup”>22;#Soap Discussion</Field>
</Method>
</Batch>
</updates>
</UpdateListItems>
</soap:Body>
</soap:Envelope>

where,

–  <listName> is a GUID for the list extracted from list settings url.

 

Sharepoint 2010 REST service limitations

November 10, 2012 Leave a comment

Sharepoint 2010 listdata.svc exposes REST implementation to client in order to access list items.

Below are some of short comings of using REST

i)  Access sharepoint survey using listdata.svc

Recently i had a requirement to expose the sharepoint survey questions and choices to the client

via REST Service.While exposing we found that the survey questions and choices are in REST format

in the response.

http://<Server_Name>/_vti_bin/listdata.svc/<SURVEYNAME>+”Item”

Limitations:

a)  i.e. Do you like to play cricket? becomes DoYouLikeToPlayCricket?

By this way client have no clues to display the readable format of the questions.

in order to retain the format.

Moreover if the survey doesn’t  contain any response then there is no way to retrive the questions

from the listadata.svc.

Workaround:

In order to overcome the above restrictions,i have decided to create a new list with columns contains

survey questions with below format such as,

i)Do you like to play cricket? – (Readable format)

ii)DoYouLikeToPlayCricket       -(REST format)

ii)Name of the Survey

Now client can able to get the survey questions even if the survey doesn’t contains any response. But we need to make sure

whenever the survey questions are added/edited the same should be updated in a new list created by us.we can also achive this by

using ECMA client object model.

Note:       The above mentioned limitation can also be resolved by using SOAP service.But in

our case we have chosen the service layer as REST in our design.

jQuery loading issue in sharepoint pages

November 10, 2012 Leave a comment

Recently i have faced a issue with some pages in my sharepoint application jQuery is not getting loaded.

Even though i’ve cross verified path and did all checks. finally got resolution in the given post.

The reason javascript generated by sharepoint framework also contains a $ synbol for denoting variables.

By converting $ into jQuery i my script makes the issue resolved.

http://social.msdn.microsoft.com/Forums/en/sharepointgeneralprevious/thread/ba453370-9737-4f3c-9c0b-405bb76c8392