Arquivo da Categoría: SharePoint Web Services

Como especificar Persoas como un ámbito de investigación / Fonte de contido Usando o SharePoint 2013 API REST

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: función() {

        jQuery.support.cors = certo;

        $.ajax({
            url: este.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",
            método: "GET",
            headers: { "Accept": "application/json; odata=verbose" },
            cache: teito,
            success: función (resultar) {

No meu caso, 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, pero eu vou sempre comprobar calquera xeito 🙂 ).

</final>

undefinedRexístrate para o meu blog.

Siga-me no Twitter http://www.twitter.com/pagalvin

Lists.asmx, GetListItems e carpetas

Eu estaba facendo unha investigación para alguén hoxe en todo o servizo web list.asmx seleccionado como parte do SharePoint 2010 (e máis cedo).  Ela foi capaz de obter os elementos da lista no cartafol raíz (incluíndo os nomes dos subcartafoles), pero non podía elementos en subcartafoles.  I did some looking around on the internets and it’s a surprisingly common question.  Aínda, 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 sorriso.

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”.  Isto é o que parece:

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> e <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 / xabón / Sobre /’>                
  <soapenv:Corpo>
    <GetListItems xmlns=’
http://schemas.microsoft.com / SharePoint / xabón /’>
      <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:Corpo>
</soapenv:Sobre>

A lot of examples and discussion around this led me to believe that all I need was <QueryOptions> and specify a folder name.  Para min, 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:

$(documento).preparado(función() {
       var soapEnv =
           "<soapenv:Envelope xmlns:soapenv=’http://schemas.xmlsoap.org / xabón / Sobre /’> \
               <soapenv:Corpo> \
                    <GetListItems xmlns=’http://schemas.microsoft.com / SharePoint / xabón /’> \
                       <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:Corpo> \
           </soapenv:Sobre>";

</final>

Rexístrate para o meu blog.

Siga-me no Twitter http://www.twitter.com/pagalvin

Lists.asmx, GetList e "Valor non pode ser nulo”

Descubrín onte que o GetList() método lists.asmx servizo web ten que ser chamado con moito coidado ou é propenso a lanzar un misterioso "Valor non pode ser nulo" excepción (e iso supoñendo que pode pasar a mensaxe de erro aínda peor xenérico, “Exception of type ‘Microsoft.SharePoint.SoapServer.SoapServerException’ foi lanzada. ")  Especificamente, Eu penso que non pode fornecer calquera tipo de prefixo do método GetList.  O tramo a continuación ilustra o punto jQuery:

image

Se fai iso, o servizo web responde con "Valor non pode ser nulo", segundo este violinista-indicado transcrición HTTP:

<?xml version="1.0" encoding="utf-8"?>
  <xabón:Sobre
     xmlns:xabón ="
http://schemas.xmlsoap.org / xabón / Sobre /"    
     xmlns:xsi = "
http://www.w3.org/2001/XMLSchema-instance"
     xmlns:XSD ="
http://www.w3.org/2001/XMLSchema">

  <xabón:Corpo>
    <xabón:Culpa>
      <FaultCode>xabón:Servidor</FaultCode>
      <faultstring>
        Exception of type ‘Microsoft.SharePoint.SoapServer.SoapServerException’ foi lanzado.
      </faultstring>
      <detalle>
        <xmlns cadea de erro ="
http://schemas.microsoft.com / SharePoint / xabón /">
O valor non pode ser nulo.
        </errorString>
      </detalle>
    </xabón:Culpa>
  </xabón:Corpo>
</xabón:Sobre>

Por suposto, probablemente non quere engadir que o prefixo "S0" no seu propio país, pero algunhas ferramentas son propensos a facelo (como Eclipse).

Isto é aínda máis confuso / frustrante, porque outros métodos tolerar prefixos.  Por exemplo, o GetListCollection método non lle importa se foi precedido, mesmo con prefixos sen sentido como "xyzzy":

image

Este "valor non pode ser nulo" parece bastante común con lists.asmx polo que espera que isto vai axudar a alguén no futuro.

</final>

Rexístrate para o meu blog.

Siga-me no Twitter http://www.twitter.com/pagalvin