Arkivat e Kategorisë: SharePoint Web Services

Si të përcaktoni Njerëzit si Kërko Fushëveprimi / Përmbajtja Burimi Duke përdorur SharePoint 2013 REST API

I had reason to work with the SharePoint 2013 Search API via REST for the first time. I wanted to search for people, not documents. The key learning here is that you specify content sources via its GUID (or at least in this case). The following jQuery snippet shows how:

    loadExpertsAsync: funksion() {

        jQuery.support.cors = i vërtetë;

        $.ajax({
            url: kjo.CreateFullApiUrl() +
                "?querytext='portals'&sourceid='b09a7990-05ea-4af9-81ef-edfab16c4e31'" +
                "&selectproperties='LinkedInProfileUrl,GoogleCirclesProfileUrl,BALargeProfilePictureUrls,BAGridPictures,WorkEmail,Skills,AboutMe,Interests,JobTitle,PastProjects,PictureURL,PreferredName,TwitterHandle,LinkedInProfileUrl,PreferredName,GoogleCirclesProfileUrl'" +
                "&rowlimit=99",
            metodë: "GET",
            headers: { "Accept": "application/json; odata=verbose" },
            cache: i rremë,
            success: funksion (pasojë) {

Në rastin tim, I’m running the API against SharePoint online. To get the GUID, I followed these steps:

  1. Access the SharePoint admin center
  2. Select “search” from the left hand navigation
  3. Select “Manage Result Sources”
  4. Select “Local People Results”
  5. Look at the URL.

My URL looked something like:

https://xyzzy-admin.sharepoint.com/_layouts/15/searchadmin/EditResultSource.aspx?level=tenant&sourceid=b09a7990%2D05ea%2D4af9%2D81ef%2Dedfab16c4e31&view=1

The sourceid parameter is what worked for me.

(I understand that the sourceid may actually be a sort of permanent thing with SP, but I’ll always check anyway 🙂 ).

</fund>

undefinedAbonohen në blogun tim.

Atëherë ejani pas meje në Twitter në http://www.twitter.com/pagalvin

Lists.asmx, GetListItems dhe dosjet

Unë kam qenë duke bërë disa kërkime për dikë sot rreth shërbimit të internetit list.asmx ofruara si pjesë e SharePoint 2010 (dhe më herët).  Ajo ishte në gjendje për të marrë sendet listë në dosjen rrënjë (duke përfshirë edhe emrat e sub-folders), por nuk mund të merrni artikuj në sub-folders.  I did some looking around on the internets and it’s a surprisingly common question.  Ende, I couldn’t get a good answer to the simple question, “if I know the folder, how do I get the items in the folder?"  To be honest, I didn’t try all that hard since I’ve wanted to figure this one out on my own for a while buzëqeshje.

To set this up, I created a site named “Blogging Scenarios” and a custom list named “Custom List with Sub Folders”.  I then created folders named:

  • Year 2005
  • Year 2006
  • Year 2007

I added a few items to the folder “Year 2006”.  Kjo është ajo që duket si:

image

My friend isn’t writing C# code but rather using Java, so the SOAP envelope was what she really needed.  To get that, I wrote a bit of jQuery and then used fiddler to get the actual HTTP conversation.

Here’s the relevant jQuery (I copied the code down below if you want to copy/paste):

image

They first key is to include both a <queryOptions> dhe <QueryOptions> node.  The second key is that the <Folder> node is a URL to which the client has access.

There may be other ways to get this, but this worked well for me when using jQuery.

Here is the SOAP envelope for the above:

<soapenv:Envelope xmlns:soapenv=’http://schemas.xmlsoap.org / sapun / Zarfi /’>                
  <soapenv:Trup>
    <GetListItems xmlns=’
http://schemas.microsoft.com / SharePoint / sapun /’>
      <listName>Custom List with Sub Folders</listName>
      <viewFields>  
        <ViewFields>
          <FieldRef Name=’Title’ />
          <FieldRef Name=’EncodedAbsUrl’ />
        </ViewFields>
      </viewFields>
      <queryOptions>
        <QueryOptions>
          <Folder>
http://demoserver1/Blogging Scenarios/lists/Custom List with Sub Folders/Year 2006</Folder>
        </QueryOptions>
      </queryOptions>
   
</GetListItems>
  </soapenv:Trup>
</soapenv:Zarf>

A lot of examples and discussion around this led me to believe that all I need was <QueryOptions> and specify a folder name.  Për mua, I need to both wrap it inside <queryOptions> as well as specify a fully qualified URL for the <Folder> node.

Here’s the jQuery AJAX setup:

$(dokument).gati(funksion() {
       var soapEnv =
           "<soapenv:Envelope xmlns:soapenv=’http://schemas.xmlsoap.org / sapun / Zarfi /’> \
               <soapenv:Trup> \
                    <GetListItems xmlns=’http://schemas.microsoft.com / SharePoint / sapun /’> \
                       <listName>Custom List with Sub Folders</listName> \
                       <viewFields> \
                           <ViewFields> \
                              <FieldRef Name=’Title’ /> \
                              <FieldRef Name=’EncodedAbsUrl’ /> \
                          </ViewFields> \
                       </viewFields> \
                       <queryOptions> \
                         <QueryOptions> \
                           <Folder>http://demoserver1/Blogging Scenarios/lists/Custom List with Sub Folders/Year 2006</Folder> \
                         </QueryOptions> \
                       </queryOptions> \
                   </GetListItems> \
               </soapenv:Trup> \
           </soapenv:Zarf>";

</fund>

Abonohen në blogun tim.

Atëherë ejani pas meje në Twitter në http://www.twitter.com/pagalvin

Lists.asmx, GetList dhe "Vlera nuk mund të jetë null”

Kam zbuluar sot se GetList() Metoda në lists.asmx web shërbim ka për t'u quajtur me shumë kujdes ose ajo është i prirur për të hedhur një misterioze "Vlera nuk mund të jetë null" përjashtim (dhe kjo është duke supozuar që ju mund të merrni kaluara mesazh gabimi edhe më keq gjenerik, “Exception of type ‘Microsoft.SharePoint.SoapServer.SoapServerException’ u hodh. ")  Në mënyrë të veçantë, Kam gjetur se ju nuk mund të japin asnjë lloj prefiksi mbi metodën GetList.  JQuery snippet vijim ilustron pikën:

image

Nëse ju bëni që, shërbim web përgjigjet me "Vlera nuk mund të jetë i pavlefshëm" si për këtë violinist-me kusht transkript HTTP:

<?xml version="1.0" encoding="utf-8"?>
  <sapun:Zarf
     xmlns:Sapun ="
http://schemas.xmlsoap.org / sapun / Zarfi /"    
     xmlns:XSi = "
http://www.w3.org/2001/XMLSchema-instance"
     xmlns:XSD ="
http://www.w3.org/2001/XMLSchema">

  <sapun:Trup>
    <sapun:Faj>
      <faultcode>sapun:Server</faultcode>
      <faultstring>
        Exception of type ‘Microsoft.SharePoint.SoapServer.SoapServerException’ u hodh.
      </faultstring>
      <hollësi>
        <xmlns string error ="
http://schemas.microsoft.com / SharePoint / sapun /">
Vlera nuk mund të jetë null.
        </errorstring>
      </hollësi>
    </sapun:Faj>
  </sapun:Trup>
</sapun:Zarf>

Sigurisht, ju ndoshta nuk do të shtoja se "s0" prefiks në tuaj, por disa mjete janë të prirur për të bërë atë (si Eclipse).

Kjo është e gjitha shumë konfuz / frustruese sepse metoda të tjera të tolerojë prefikset.  Për shembull, the GetListCollection metodë nuk parasysh nëse ajo është prefixed, madje edhe me prefikset pakuptimta si "xyzzy":

image

Kjo "nuk mund të jetë vlera null" duket mjaft e zakonshme me lists.asmx kështu që shpresojmë se kjo do të ndihmojë dikë në të ardhmen.

</fund>

Abonohen në blogun tim.

Atëherë ejani pas meje në Twitter në http://www.twitter.com/pagalvin