2017-07-05 2 views
0

Je suis en train d'écrire un appel ajax pour récupérer des éléments de liste de SharePoint à l'aide Lists.asmxUtilisation GetListItems avec appel Ajax à partir de SharePoint 2010

Je continue à obtenir une erreur 302 même si je suis folling le formatage correctement. Est-ce que je manque quelque chose?

code

function makeSoapCall(listName){ 
    var soapEnv = 
    "<?xml version='1.0' encoding='utf-8'?> " + 
    "<soap12:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap12='http://www.w3.org/2003/05/soap-envelope'> " + 
     "<soap12:Body> " + 
      "<GetList xmlns='http://schemas.microsoft.com/sharepoint/soap/'> " + 
       "<listName>Webpostings Approvers</listName> " + 
      "</GetList> " + 
     "</soap12:Body> " + 
    "</soap12:Envelope>"; 

     $.ajax({ 
      url: "http://webpub.ex.com/_vti_bin/Lists.asmx", 
      type: "POST", 
      dataType: "xml", 
      data: soapEnv, 
      contentType: "application/soap+xml; charset=utf-8" 
     }); 
    } 

Réponse

http://webpub.ex.com/_layouts/error.aspx?ErrorText=Request format is unrecognized. 

Répondre

0

Puisque vous avez besoin des éléments de liste. Vous devez utiliser Getlistitems à la place Getlist.

function getSharepointListData (myList) { 

     var listName = myList; 

    var soapEnv = 
     "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \ 
      <soapenv:Body> \ 
       <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \ 
        <listName>"+listName+"</listName> \ 
        <viewFields> \ 
         <ViewFields> \ 
          <FieldRef Name='Author' /> \ 
         </ViewFields> \ 
        </viewFields> \ 
       </GetListItems> \ 
      </soapenv:Body> \ 
     </soapenv:Envelope>"; 

    $.ajax({ 
     url: "http:URL/_vti_bin/lists.asmx", 
     type: "POST", 
     dataType: "xml", 
     data: soapEnv, 
     complete: processResult, 
     contentType: "text/xml; charset=\"utf-8\"" 
    });