[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

SOAP Error when trying to add an item to a SharePoint list using javascript / jquery

Asked by MrExcel1981 in JavaScript, SOAP, MS SharePoint

Hi

I am trying to add an item to a sharepoint list using javascript but I get an error.  The code is below.  The error I get is:

<?xml version="1.0"?>
<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><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.</faultstring><detail><errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).</errorstring></detail></soap:Fault></soap:Body></soap:Envelope>

I am pulling my hair out can someone please help!  The list only has a title field.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml">
 
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled 1</title>
</head>
 
<body>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
 
    <script>
        $(document).ready(function() {
            $("#newTaskButton").click(function() {
                CreateNewItem($("#newTaskTitle").val());
            });
        });
 
        function CreateNewItem(title) {
            // The CAML to create a new item and set the Title field.
            var batch =
                "<Batch OnError=\"Continue\"> \
                    <Method ID=\"1\" Cmd=\"New\"> \
                        <Field Name=\"Title\">" + title + "</Field> \
                    </Method> \
                </Batch>";
 
            // The SOAP Envelope
            var soapEnv =
                "<?xml version=\"1.0\" encoding=\"utf-8\"?> \
                <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \
                    xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" \
                    xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> \
                  <soap:Body> \
                    <UpdateListItems xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\"> \
                      <listName>Test_Service</listName> \
                      <updates> \
                        " + batch + "</updates> \
                    </UpdateListItems> \
                  </soap:Body> \
                </soap:Envelope>";
 
            // Build the URL of the Lists.asmx web service.
            // This is done by stripping the last two parts (/doclib/page) of the URL.
            var hrefParts = window.location.href.split('/');
            var wsURL = "";
            for (i = 0; i < (hrefParts.length - 2); i++) {
                if (i > 0)
                    wsURL += "/";
                wsURL += hrefParts[i];
            }
            wsURL += "/_vti_bin/lists.asmx";
 
            // Make the call by posting the SOAP Envelope.
            $.ajax({
                url: wsURL,
                beforeSend: function(xhr) {
                    xhr.setRequestHeader("SOAPAction",
                    "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems");
                },
                type: "POST",
                dataType: "xml",
                data: soapEnv,
                complete: processResult,
                contentType: "text/xml; charset=utf-8"
            });
 
        }
 
        function processResult(xData, status) {
            // Process the result.
            $("#responseStatus").text(status);
            $("#responseXML").text(xData.responseXML.xml);
        }
    </script>
 
 
	Task Title:
    <input id="newTaskTitle" type="text" />
    <input id="newTaskButton" type="button" value="Create Task" />
    <h5>
        Response:
        <label id="responseStatus">
            N/A
        </label>
    </h5>
    <p id="responseXML">
    </p>
 
</body>
 
</html>
 
Related Solutions
Keywords: SOAP Error when trying to add an item…
 
Loading Advertisement...
 
[+][-]11/05/09 02:21 AM, ID: 25748070Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 02:24 AM, ID: 25748084Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/05/09 02:44 AM, ID: 25748190Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 02:56 AM, ID: 25748228Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/05/09 03:10 AM, ID: 25748303Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 04:28 AM, ID: 25748705Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/05/09 04:52 AM, ID: 25748855Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 05:47 AM, ID: 25749345Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/05/09 05:59 AM, ID: 25749461Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/09/09 04:30 AM, ID: 25775257Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/10/09 05:21 AM, ID: 25785030Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89 - Hierarchy / EE_QW_3_20080625